Write a C Program to display Your Own Name.

Prince Patel
By -
0

Write a C Program to display Your Own Name.


In this Article, you will learn how to display your own name in C Programming.

#include<stdio.h>
#include<conio.h>

void main()
{
    char name[20];
    printf("Enter name: ");
    scanf("%s", name);

    printf("Your name is %s.", name);
}


This program uses a character array name to store the user's input. It prompts the user to enter their name using printf and reads the input using scanf. Then, it prints the entered name back to the user using printf.

When you run this program, it will ask you to enter your name, and after you provide the input, it will display your name on the screen. For example:

Output:

Keep in mind that this program assumes the user enters a single-word name without spaces. If you need to handle multi-word names with spaces, you can use fgets to read the input instead of scanf.
Tags:

Post a Comment

0Comments

Post a Comment (0)