Can You Build a Shopping Bill Using C?
Imagine you go to a shop and buy:
-
2 notebooks × ₹50
-
3 pens × ₹10
How does the computer calculate your total bill?
Today, we'll build a simple shopping-bill program in C! 💻
#include <stdio.h>
int main() {
int notebooks, pens;
int total;
printf("Enter number of notebooks: ");
scanf("%d", ¬ebooks);
printf("Enter number of pens: ");
scanf("%d", &pens);
total = (notebooks * 50) + (pens * 10);
printf("Your total bill is: ₹%d", total);
return 0;
}
🎯 What you learn from this one small program:
• How variables store information
• How scanf() takes input
• How printf() displays output
• How multiplication and addition work in a program
• How a real-world problem can be converted into code
And this is just the beginning! From here, we can turn the same idea into a discount calculator, restaurant bill, ATM program, student marks calculator and much more.
💡 My teaching approach: I don't want students to just memorize C syntax. I want them to understand why we write each line and connect programming concepts to things they see in everyday life.
Let's make coding feel less like a subject and more like solving real problems! 🚀
0