C Programming – Day 3 | Conditional Statements (if, else, else-if, switch) for Beginners
CONDITIONAL STATEMENTS (if, else, else-if, switch)
DAY - 3
✅ We’ll continue the learning smoothly.
📍 Day-3 — Conditional Statements (if, else, else-if, switch)
Today you will learn:
1️⃣ If statement
2️⃣ If…Else
3️⃣ Else-If Ladder
4️⃣ Nested If
5️⃣ Switch-Case
6️⃣ Mini Project + Quiz
✅ 1. If Statement
Executes code only if condition is true ✅
int age = 18;
if(age >= 18){
printf("Adult");
}
✅ 2. If…Else
int n;
scanf("%d", &n);
if(n % 2 == 0)
printf("Even");
else
printf("Odd");
✅ 3. Else-If Ladder
Used when multiple conditions exist
int marks;
scanf("%d", &marks);
if(marks >= 80)
printf("A+");
else if(marks >= 70)
printf("A");
else if(marks >= 60)
printf("B");
else
printf("Fail");
✅ 4. Nested If
int age = 20;
if(age > 0) {
if(age >= 18)
printf("Adult");
else
printf("Child");
}
✅ 5. Switch-Case
Used for menu-type choices
int choice;
scanf("%d", &choice);
switch(choice) {
case 1: printf("Tea"); break;
case 2: printf("Coffee"); break;
default: printf("Water");
}
✅ Use break to stop falling into the next case
✅ default = else
🧪 Practice Example
#include <stdio.h>
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
if(num > 0)
printf("Positive");
else if(num < 0)
printf("Negative");
else
printf("Zero");
return 0;
}
✅ Task-3 (You Must Solve)
Write a program:
✔ Input a number
✔ Check:
-
If multiple of 3 and 5, print:
Divisible by both -
Else if only divisible by 3, print:
Divisible by 3 -
Else if only divisible by 5, print:
Divisible by 5 -
Otherwise:
Not divisible
📌 Hint: Use % operator
📌 Use if…else-if
Example outputs:
Divisible by both
or
Not divisible
✅ Send me your code — I will correct and add.
📝 Quick Quiz — Day-3
Reply like: 1B, 2A, 3C
1️⃣ Which statement is used for multi-way menu?
A) if
B) switch
C) else
2️⃣ Condition true → if block executes
A) True
B) False
3️⃣ Which keyword stops falling into next case?
A) else
B) return
C) break
✅ When you reply with:
✔ Task-3 Code
✔ Quiz Answers
➡ I will mark Day-3 Completed
Send your Task-3 solution now — I’m ready to check! 😄

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