printf function

When the c program needs to communicate with the user, We should use printf function.

The communication can be,

Greeting the user

"welcome to c program"

Asking input from the user

"Enter your username/password" etc.


printf function is defined in stdio.h header file.

So if we want to use the printf function in our c program, we should include stdio.h header file.

Syntax of printf


It will print characters to the screen which is given inside the double quotes "" .

And it should end up with a semicolon ;.


printf("Hello World");

printf("Enter two numbers");


Sample Program


#include<stdio.h>     //header section 

int main()             //main section 
    printf("Welcome to the C Programming");

    return 0;

Correct the below program

The below program has some syntax errors.

Correct the program by yourself and see the output.



int main()
    printf("Correct me!)

    return 0;

Useful Resources

Topics You Might Like