
Example: ‘C’ Program to get input from a user using scanf command
-
#include <stdio.h>
-
int main()
-
{
-
int x;
-
printf(“Input an integer\n”);
-
scanf(“%d”, &x); // %d is used for an integer
-
printf(“The integer is: %d\n”, x);
-
return 0;
-
}
Output:
Input an integer
7897
The integer is: 7897