input

We are providing Input whenever we feed data into a program. Input is achieved by using the standard input/output library. To include the library we need to add the stdio header:

#include <stdio.h>

Then we have access to the scanf() function. The scanf() function reads input from the standard input/output stream, stdin and scans the input. We can use scanf() to get user input. scanf() takes 2 arguments, the format specifier of the variable and the reference operator. Table 1 shows the different format specifiers.

scanf("%A", &variableOfAType);

The reference operator stored the memory address of the variable. scanf() can be used to accept multiple inputs!

scanf("%d" %c, &myNum, &myChar);
data typevalue of A
int%d
float%f
char%c
long%l or %ld
double%lf
format specifier for different data types