VOOZH about

URL: https://www.geeksforgeeks.org/c/c-program-to-print-your-own-name/

⇱ C Program To Print Your Own Name - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C Program To Print Your Own Name

Last Updated : 23 Jul, 2025

Printing your own name means displaying your name on the computer screen. In this article, we will learn how to print your own name using a C program.

Examples

Input: name = "Rahul"
Output: Rahul
Explanation: The program prints "Rahul" to the screen.

Input: name = "Vikas"
Output: Vikas
Explanation: The program prints "Vikas" to the screen.

Print Your Own Name Using printf()

The simplest way to print something is to use the printf() function. You can provide your name in the form of string to printf() function and it will print it on the output screen.

Syntax of printf

printf("your_name_here")

Program to Print Your Own Name Using printf


Output
Rahul

Other Different Ways to Print Your Own Name in C

Apart from the printf function, we can also print our name on the screen using other methods provided in C:

Take Your Name as Input and Then Print It

We can use scanf() function to take the name as input from the user and store it in a character array. We can then use printf function to print the name on the screen.

Syntax of scanf()

scanf("%s", charArr);

Program to Print Your Own Name by Taking it as Input


Output

Enter Your Name: Rahul
Your Name: Rahul

Using puts()

The puts() function is another function that is used to print the given string to the output screen. It is also defined inside the <stdio.h> header file.

Syntax of puts()

puts("name");

Program to Print Your Own Name Using puts()


Output
Vikas

Using fputs()

The fputs() function is used for file output. We can redirect this function to standard output buffer "stdout" to print your name on the console screen.

Syntax

fputs("name", stdout);

Program to Print Your Own Name Using fputs()


Output
Robert

Using fprintf()

The fprintf()function is used also for file output. It is similar to the printf function, but we need to specify the output buffer in the function which in this case is stdout.

Syntax

fprintf("name", stdout);

Program to Print Your Own Name Using fprintf()


Output
Robert

Using Write System Call

The write() function performs the write system call to the operating system which is used to write some data to some specific file. We can use this print your name by directly writing it to the output buffer.

Syntax of write()

write(STDOUT_FILENO, "name", strlen("name"));

STDOUT_FILENO is the file descriptor for the stdout buffer. Its value is 1 by standard.

Program to Print Your Own Name Using Write System Call


Output
Gabriel
Comment
Article Tags: