C Program To Print Your Own Name
Last Updated :
18 Mar, 2024
Here, we can use the 2 different approaches to print the name:
- Using printf()
- Using scanf()
Input:
Enter Name = Mukul
Output:
Name = Mukul
Example 1: In this example, we print the user name using printf() function.
C
// C program to demonstrate printing of
// our own name using printf()
#include <stdio.h>
int main()
{
// print name
printf("Name : GeeksforGeeks");
return 0;
}
OutputName : GeeksforGeeks
Example 2: In this example, we use scanf() to accept the name as input from the user and then print it.
C
// C program to demonstrate printing of
// our own name using scanf()
#include <stdio.h>
int main()
{
char name[20];
printf("Enter name: ");
// user input will be taken here
scanf("%s", name);
printf("Your name is %s.", name);
return 0;
}
Output:
Enter name: Mukul
Your name is Mukul.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...