C Programming – Day 4 | Loops in C (for, while, do-while) Explained for Beginners
LOOP IN C (for, while, do-while)
DAY - 4
let’s begin 🚀
📍 Day-4 — Loops in C (for, while, do-while)
Loops repeat a block of code many times ✅
✅ 1️⃣ for Loop
Used when number of repetitions is known
Output:
✅ 2️⃣ while Loop
Used when number of repetitions is unknown
✅ 3️⃣ do-while Loop
Executes block at least once
✅ Difference Summary
| Feature | for | while | do-while |
|---|---|---|---|
| Initialization in loop | Yes | No | No |
| Condition check first | ✅ Yes | ✅ Yes | ❌ Executes once first |
| Guaranteed at least once? | ❌ No | ❌ No | ✅ Yes |
🧮 Example: Multiplication Table
✅ Task-4
Write a program to:
✔ Input a number
✔ Using while loop
✔ Print sum of digits
Example:
(Because 4+5+6 = 15)
📌 Hint:
-
%10→ last digit -
/10→ remove last digit
✅ Send me your code — I will fix if needed
📝 Quick Quiz — Day-4
Reply like: 1C, 2A, 3B
1️⃣ Which loop runs at least once always?
A) for
B) while
C) do-while
2️⃣ Repeat 1 to 10 → which loop is best?
A) for
B) while
C) switch
3️⃣ %10 gives:
A) Division
B) Last digit
C) Whole number
✅ Your turn now!
Send:
👉 Task-4 code
👉 Day-4 quiz answers

No comments
Thank You For Visit My Website.
I Will Contact As Soon As Possible.