๐ป Day 84: Conditional Statements in C – Hinglish
๐ป Conditional Statements in C –
๐ Aaj hum seekhenge:
✅ Conditional statement kya hai
✅ Types (if, if-else, else-if, switch)
✅ Examples
(Programming ka very important topic) ๐ฏ
๐ Conditional Statement kya hai?
๐ Jab program me condition lagate hain,
ki agar ye hoga to ye kaam karo, warna kuch aur karo.
➡️ Simple words me:
Condition = Agar / Nahi to logic.
๐งฉ Types of Conditional Statements
1️⃣ if Statement
๐ Sirf condition true hone par code chalega.
Example:
#include <stdio.h>
int main() {
int a = 10;
if (a > 5) {
printf("A is greater than 5");
}
return 0;
}
2️⃣ if-else Statement
๐ Agar condition true ho to if, warna else chalega.
Example:
#include <stdio.h>
int main() {
int a = 3;
if (a > 5) {
printf("A is greater than 5");
} else {
printf("A is not greater than 5");
}
return 0;
}
3️⃣ else-if Ladder
๐ Multiple conditions ke liye.
Example:
#include <stdio.h>
int main() {
int marks = 75;
if (marks >= 90) {
printf("Grade A");
}
else if (marks >= 60) {
printf("Grade B");
}
else {
printf("Grade C");
}
return 0;
}
4️⃣ switch Statement
๐ Multiple choices ke liye.
Example:
#include <stdio.h>
int main() {
int day = 2;
switch(day) {
case 1:
printf("Monday");
break;
case 2:
printf("Tuesday");
break;
default:
printf("Invalid day");
}
return 0;
}
๐งช Practice Questions
✅ Theory:
Conditional statement kya hai?
if aur if-else me difference likho.
switch statement kya hai?
✅ Practical:
๐ Program likho:
Even / Odd number check
Marks se grade print karo
๐ Short Notes (Exam ke liye)
๐ if = condition check
๐ else = otherwise
๐ switch = multiple choice