Skip to content
Related Articles

Related Articles

C Program To Print Your Own Name

View Discussion
Improve Article
Save Article
  • Last Updated : 02 Aug, 2022
View Discussion
Improve Article
Save Article

Here, we can use the 2 different approaches to print the name:

  1. Using printf()
  2. 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;
}

Output

Name : 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:

Output of your own name

Output of our own name

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!