What if your program could listen and respond to anyone who uses it?
Why Using scanf for input? - Purpose & Use Cases
Imagine you want to ask your friend for their age and then write it down. Doing this by guessing or writing it on paper without asking directly is like trying to get input in a program without a proper tool.
Without a way to get input, you have to hardcode values or change the program every time you want different data. This is slow, boring, and full of mistakes because you can't easily change what the program uses.
Using scanf lets your program ask the user for input directly. It waits for the user to type something and then stores it in a variable. This makes your program flexible and interactive.
int age = 25; // fixed value, no user inputint age;
scanf("%d", &age); // reads user input into ageIt lets your program talk to people and use their answers to do different things every time.
Think of a quiz game that asks your name and age before starting. Using scanf, the game can greet you personally and adjust questions based on your age.
Without input, programs are stuck with fixed data.
scanf reads user input and stores it in variables.
This makes programs interactive and flexible.