C Output

In C, the printf() function is used to display output on the screen. The function is included in the stdio.h header file and has the following syntax:

printf("format string", argument1, argument2, ...);

The format string is a string of characters that specifies how the output should be formatted, and the arguments are variables or expressions that are inserted into the output.

Some common format specifiers that can be used in the format string are:

  • %d: Used for displaying integers.
  • %f: Used for displaying floating-point numbers.
  • %c: Used for displaying characters.
  • %s: Used for displaying strings.
  • %p: Used for displaying memory addresses.


#include <stdio.h>

int main() {
   int age = 25;
   float salary = 2500.50;
   char name[] = "John";
   printf("Name: %s\n", name);
   printf("Age: %d\n", age);
   printf("Salary: %.2f\n", salary);
   return 0;

This program will display the following output:

Name: John
Age: 25
Salary: 2500.50

The printf() function is an important tool for debugging and displaying information in a program. It can be used to display variable values, error messages, and other important information for the user.

Wordpress Social Share Plugin powered by Ultimatelysocial
Wordpress Social Share Plugin powered by Ultimatelysocial