In C programming, printf()
is one of the main output function. The function sends formatted output to the screen. For example,
Example 1: C Output
#include <stdio.h>
int main()
{
// Displays the string inside quotations
printf("C Programming");
return 0;
}
Output
C Programming
How does this program work?
- All valid C programs must contain the
main()
function. The code execution begins from the start of themain()
function. - The
printf()
is a library function to send formatted output to the screen. The function prints the string inside quotations. - To use
printf()
in our program, we need to includestdio.h
header file using the#include <stdio.h>
statement. - The
return 0;
statement inside themain()
function is the “Exit status” of the program. It’s optional.