Write a Program to Display your Name in C
- Here is the C program to print your own name.
- Here, we can use the 2 different approaches to print the name:
- Using printf()
- Using scanf()
C program that uses printf() to print your own name
#include
int main() {
printf("My name is [Your Name].\n");
return 0;
}
Output
C program that uses scanf() to read your name
#include
int main() {
char name[50];
printf("Enter your name: ");
scanf("%s", name);
printf("My name is %s.\n", name);
return 0;
}
Output

Using
printf()
, we display the prompt “Enter your name: “. Then, usingscanf()
, we read the input entered by the user and store it in thename
variable.Finally, we use
printf()
again to display the entered name as “My name is [Your Name].”When you run this program, it will prompt you to enter your name. After entering your name and pressing Enter, it will display your name on the console.
SELECT AVG(emp_sal)
FROM employee;
SELECT COUNT(*)
FROM employee;