This program demonstrates how to read input from the keyboard and display it on the screen using standard input and output functions.
main.c
Copy to clipboard
#include <stdio.h>
int main()
{
int number;
printf("Enter a number: ");
scanf("%d", &number);
printf("You entered: %d\n", number);
return 0;
}
Output:
Enter a number: 10
You entered: 10
scanf() is used to read input from standard input (keyboard). The format specifier %d indicates that an integer value is expected.
The variable address is passed using &number, allowing scanf() to store the input value in memory.
printf() is used to display the entered value. The same format specifier %d is used to print the integer.
Execution starts from main() and the program terminates after returning 0.