Formatted and Unformatted Input Output
Functions in C
Formatted Input/Output Functions:
Formatted I/O enables you to read or write data in a certain format.
printf()and scanf() are two examples of C functions that handle formatted I/O. The
type and format of the data to be read or written are specified by format strings,
which are used by these operations. The program's execution replaces the
placeholders for the data found in the format strings with the actual data.
➢ Why they are called Formatted I/0 Functions?
These functions are called formatted I/O functions as they can use format
specifiers in these functions. Moreover, we can format these functions
according to our needs.
Here are the list of some specifiers:
, 1. scanf()
We use the scanf() function for getting the formatted inputs or standard inputs so that
the printf() function can provide the program with numerous options of conversion.
Syntax for scanf()
scanf (format_specifier, &data_a, &data_b,……); // Here, & refers to the address
operator
The purpose of the scanf() function is to read the characters that we get from the
standard input, convert them according to the string of format specification, and then
store the available inputs in the memory slots that the other arguments represent.
2. printf()
We use the printf() function for generating the formatted outputs or standard outputs
in accordance with a format specification. The output data and the format
specification string act as the parameters of the function printf().
Syntax for printf()
printf (format_specifiers, info_a, info_b,…….. );
The character that we specify after the ‘%’ character refers to the conversion character. It is
because ‘%’ allows the conversion of any given data type into another data type for further
printing.
#include<stdio.h>
void main()
{
int a;
printf(“Enter value of a:”);
Functions in C
Formatted Input/Output Functions:
Formatted I/O enables you to read or write data in a certain format.
printf()and scanf() are two examples of C functions that handle formatted I/O. The
type and format of the data to be read or written are specified by format strings,
which are used by these operations. The program's execution replaces the
placeholders for the data found in the format strings with the actual data.
➢ Why they are called Formatted I/0 Functions?
These functions are called formatted I/O functions as they can use format
specifiers in these functions. Moreover, we can format these functions
according to our needs.
Here are the list of some specifiers:
, 1. scanf()
We use the scanf() function for getting the formatted inputs or standard inputs so that
the printf() function can provide the program with numerous options of conversion.
Syntax for scanf()
scanf (format_specifier, &data_a, &data_b,……); // Here, & refers to the address
operator
The purpose of the scanf() function is to read the characters that we get from the
standard input, convert them according to the string of format specification, and then
store the available inputs in the memory slots that the other arguments represent.
2. printf()
We use the printf() function for generating the formatted outputs or standard outputs
in accordance with a format specification. The output data and the format
specification string act as the parameters of the function printf().
Syntax for printf()
printf (format_specifiers, info_a, info_b,…….. );
The character that we specify after the ‘%’ character refers to the conversion character. It is
because ‘%’ allows the conversion of any given data type into another data type for further
printing.
#include<stdio.h>
void main()
{
int a;
printf(“Enter value of a:”);