Printf Conversion Specifiers for integer, float and char value - C Data Type

C examples for Data Type:Introduction

Introduction

Conversion specifiers has two parts:

  • The first character is the percent sign (%),
  • the second is a special character that tells the program how to convert the data.

The following table describes the most common conversion specifiers.

Conversion Specifier Description
%d Displays integer value
%f Displays floating-point numbers
%c Displays character

Demo Code

#include <stdio.h> 
int main()//from  ww w .j a  v  a 2  s. co m
{ 
   //variable declarations 

   int x; 
   float y; 
   char c; 

   //variable initializations 

   x = -10000; 
   y = 12123.11232; 
   c = 'A'; 

   //printing variable contents to standard output 
   printf("\nThe value of integer variable x is %d", x); 
   printf("\nThe value of float variable y is %f", y); 
   printf("\nThe value of character variable c is %c\n", c); 
}

Result


Related Tutorials