Simple Example Program For Printf


In C,the printf function writes a formatted string.

Format Specifiers

  • %c char single character
  • %d (%i) int signed integer
  • %e (%E) float or double exponential format
  • %f float or double signed decimal
  • %g (%G) float or double use %f or %e as required
  • %o int unsigned octal value
  • %p pointer address stored in pointer
  • %s array of char sequence of characters
  • %u int unsigned decimal
  • %x (%X) int unsigned hex value


printf("Text to be displayed : %format_specifiers", variable);

Simple Example For Print a Number

/* Example program to print a number In C Programming Language*/
// Header Files

//Main Function
int main()
	// Assigining the variable num
	int num=100;
	// Printing the output
	printf("Printing a number:%d",num);
	// Output screen waits until get a character
	// Returning to the main function
	return 0;

Sample Output:

Printing a number:100