Pages

Showing posts with label C programming. Show all posts
Showing posts with label C programming. Show all posts

Wednesday, July 13, 2011

The printf() Function in C and C++

Function Name: printf()
Function Header: <stdio.h> 
Declaration: int printf(const char *format [ ,argument ,...]);
Return Value: printf() sends formatted output to stdin.

The printf() function is used to print something on the output window. It prints the strings which are written within quotation. The printf() function is also used to print formatted output.




The example of printf() function

#include<stdio.h>
#include<conio.h>

void main()
{
   clrscr();
   printf("Welcome to C programming");
   getch();
}

Output


The printf() is mostly used to print formatted output. An example is given below for showing how to print formatted output with printf() function.

#include<stdio.h>
#include<conio.h>

void main()
{
  clrscr();
  printf("I like %c %s",'C',"very much");
  getch();
}

Output