🟡 Control Flow · Lesson 10
If-Else Statements
If-Else Statements
Decision Making
if-else lets a program choose what to do based on a condition.
Grade Example
int marks = 82;
if (marks >= 90) {
System.out.println("A+");
} else if (marks >= 75) {
System.out.println("A");
} else if (marks >= 33) {
System.out.println("Pass");
} else {
System.out.println("Fail");
}A
Summary
ifruns a block when its condition is true.else ifadds choices;elseis the fallback.
Decision Making
if-else program को condition के आधार पर चुनने देता है कि क्या करे।
Grade Example
int marks = 82;
if (marks >= 90) {
System.out.println("A+");
} else if (marks >= 75) {
System.out.println("A");
} else if (marks >= 33) {
System.out.println("Pass");
} else {
System.out.println("Fail");
}A
सारांश
ifcondition true होने पर block चलाता है।else ifchoices जोड़ता है;elsefallback है।
💻 Live Code Editor
Is page ke program yahan ready hain — chalाएं, badlें aur seekhें. Bina kuch install kiye.
Powered by OneCompiler. Editor mein code apne aap aa jata hai — Run dabaakर output dekhें.
Agar load na ho to naye tab mein kholें.