C Program To Print Your Own Name

Last Updated : 18 Aug, 2026

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.

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.

C
#include <stdio.h>

int main() {
  
    // Printing your name "Rahul" on the output screen
    printf("Rahul");

    return 0;
}

Output
Rahul

Syntax

printf("your_name_here")

Different Ways to Print Your Own Name

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

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.

C
#include <stdio.h>

int main() {
  
    // Defining string (character array) assuming 100
    // characters at max
    char name[100];

    // Taking input from the user
    printf("Enter Your Name: ");
    scanf("%s", name);

    // Printing your name to the screen
    printf("Your Name: %s\n", name);

    return 0;
}


Output

Enter Your Name: Rahul
Your Name: Rahul

Syntax

scanf("%s", charArr);

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.

C
#include <stdio.h>

int main() {
  
    // Print the name "Vikas" on the output screen
    puts("Vikas");

    return 0;
}

Output
Vikas

Syntax

puts("name");

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.

C
#include <stdio.h>

int main() {
  
    // Print the name "Robert" on the screen
    fputs("Robert", stdout);

    return 0;
}

Output
Robert

Syntax

fputs("name", stdout);

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.

C
#include <stdio.h>

int main() {
    // Print the name "Robert" on the screen
    fputs("Robert", stdout);

    return 0;
}

Output
Robert

Syntax

fprintf("name", stdout);

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.

C
#include <unistd.h>
#include <string.h>

int main() {
  
    // Define the name string
    char name[] = "Gabriel";

    // Print the name using the write system call
    write(STDOUT_FILENO, name, strlen(name));

    return 0;
}

Output
Gabriel

Syntax

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

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

Comment