
In this article, We are sharing C Program to Print Your Own Name and we are giving 2 Approaches to do this Task. If you Like the Article , Do share it with the People.
C Program to Print Your Own Name
Approach 1 :
#include <stdio.h>
int main() {
printf("My name is [insert your name here]!\\n");
return 0;
}Replace [insert your name here] with your actual name, and then compile and run the program. The output should be:
My name is [your name]!Approach 2 :
#include <stdio.h>
int main() {
char name[50];
printf("Please enter your name: ");
scanf("%s", name);
printf("Your name is %s!\\n", name);
return 0;
}In this program, we first declare a character array name with a size of 50. Then we use printf to prompt the user to enter their name. After that, we use scanf to read in the user’s input and store it in the name array. Finally, we use printf again to print out the user’s name.
When you run the program, you should see something like this:
Please enter your name: [type your name here]
Your name is [your name]!Other C programming examples you can Read:
