Printf and Scanf Example in C
On this page (6sections)
About this program
This is an example program in **data input and output programs in c **. Read the concept first: printf and scanf in C, then study the code and output below.
Definition of Printf And Scanf :
scanf is a function that reads formatted data from stdin.h and then writes the results into the arguments given. The printf built-in function writes output to an implementation.
Synatx:
printf("Text to be displayed : %access_specifiers", variable);
scanf(const char *format, variable);
Example Program for Printf and Scanf:
/*##Printf And Scanf*/
/*##I/O Programs, Basic Programs*/
/*##Example*/
#include <stdio.h>
int main()
{
char ch;
char str[100];
printf(?Enter any character \n?);
scanf(?%c?, &ch);
printf(?Entered character is %c \n?, ch);
printf(?Enter any string ( upto 100 character ) \n?);
scanf(?%s?, &str);
printf(?Entered string is %s \n?, str);
}
Sample Output:
Enter any character
a
Entered character is a
Enter any string ( upto 100 character )
hai
Entered string is hai
Related Pages
Learn the concept first, then study the code:
- C Programs — Browse all C Programs.
- printf and scanf in C — Tutorial — formatted input and output.
- Data Input and Output gets and puts Example Program In C — More in data input and output programs in c .
- Data Output printf and putchar Example Program In C — More in data input and output programs in c .