CHAPTER 07 / 26
C Input & Output
Learn how printf() and scanf() are used for output and keyboard input.
01 — Syntax
printf("text");\nscanf("%d", &variable);02 — Example
#include <stdio.h>
int main() {
int age;
printf("Enter age: ");
scanf("%d", &age);
printf("You entered %d", age);
return 0;
}03 — Important Points
- scanf() normally needs the address of a variable.
- Use correct format specifiers.
- Check input carefully.
04 — Common Mistakes
- Forgetting & in scanf() for normal numeric variables.
- Using the wrong format specifier.
05 — Real-World Use
Input/output concepts are used in command-line tools and educational programs.
06 — Practice
Create a small program that demonstrates the main idea of C Input & Output.