Printf And Scanf Example Program In C Programming

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.


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

#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
Entered character is a
Enter any string ( upto 100 character )
Entered string is hai