Printing Variable Contents - C Data Type

C examples for Data Type:Introduction

Introduction

To print the contents of variables, use the printf() function with a few new formatting options.

Demo Code

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

   int x; 
   float y; 
   char c; 

   //variable initializations 

   x = -1234; 
   y = 123.12; 
   c = 'M'; 

   //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