Categories
2. Input and Output

C Output

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 the main() 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 include stdio.h header file using the #include <stdio.h> statement.
  • The return 0; statement inside the main() function is the “Exit status” of the program. It’s optional.

Leave a Reply

Your email address will not be published. Required fields are marked *