Logo - ProgrammingHead

Write a Program to Display your Name in C

To write a Program to Print your Name in C, we have the printf() function in C Language.
You just have to write your Name inside the printf() function and you will be able to Print or Display your Name.

Write a Program to Display your Name in C [Updated 2026]

Steps to Print Name in C:

1) First Open Your Code-Editor/IDE
(For Example Code::Blocks / CLion / Visual Studio)
2) Create a New File And Save.
(for example myname.c)
3) Write the code As shown Above.
4) Save and Run your C Program.
(You will need a Compiler that can Compile and Run your program written in C language. for example gcc/Clang/MSVC)

C Code explanation in detail

Use of #include:

By using #include, we are including the Standard Input-Output Header file.
So #include going to include
std: standard
io: Input Output
.h: Header file extension.

Without this header file, printf() worn't work.

Use of void main()

Here main() is our Main function, where we are using void because this function is not going to return any value.
We can also use int main() or char main() depending upon the type of value we are going to return.

Use of printf()

By using printf(), we are Printing our Name or a String.
Where printf() function will take the value as an Input and Display it as an Output.

Related Topics: Write a Program to Display your Name in C [Updated 2026]

Click on Titles below to reveal the Data

Write a C Program to input name and Display

In order to Input a Name and Display it in C, we need to use two very Important C Functions,
printf() and scanf().
Where by using printf() function we will print things like "Write your name", to tell our users to Enter their name.
Then by using scanf() function we will store their entered name inside a C Variable myname.
By using scanf("%s", &myname), we are telling our compiler that we are expecting a String "%s" value and we want to store that String value inside our variable "&myname".
At the end we will Display/Print the Name using the printf() funtion. Here we are using "%s" as our String Placeholder and printf() function will print our myname variable's value there.

Writing a C program to Print the Name and Address

To print your Name and Address we can use printf() Function.
Just write your name inside The C Print Function [ printf("Name and Address"); ] and you are DONE.

Writing a program to print your name at the center of the screen

To Print your name at the center of the screen. We have to use C Languageā€˜s gotoxy() function.
Where we need to provide X and Y digits to Perfectly align our Name at the Center of the Screen.

Write a C Program to Print Names using Array

If you have Multiple Names Stored inside an Array, then you can Loop through it and Print every name One-By-One.

In the Example above, we are using char mynames[3][20] to create an Array in C.
Where are specifying the Array and Character Length. Where [3][20] means that our Array will include 3 Values with a Max 20 Character Length.

Writing a C Program to Display Name and Age

To print Name and Age we have to deal with Characters and Integer values. Where for storing Character Values we have CHAR data type and for integers with have INT data type. And for address/format specifier we have %s for String and %d for Integers.