C printf and Scanf

tutorial and example
tutorial and example

In C Language, the printf() and scanf() are inbuilt library functions that used for input and output. It is defined inthe header file“<stdio.h>”.

Printf() Function:

In C programming language, printf() function is used to print the values. The values may be character, string,float,integer etc.

We can use different types of format specifierto display the value of the program.

Format Specifier Description
%d It is used to print the value of integer variable.
%s It is used to print the value of string variable.
%c It is used to print the value of single character variable.
%f It is used to print the value of float variable.
%lf It is used to print the value of double variable.
%x It is used to print the octal value of integer variable.
%o It is used to print the hexadecimal value of integer variable.
\n It is used to break the new line.

Note:  C language is the case sensitive. All characters in printf() and scanf() functions must be in lower case.

Example of printf() function:

 

Scanf() Function:

In C program, scanf() function is used to read character,  string, numeric data from the keyboard.

Example: