🟡 Control Flow · Lesson 10
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 है।
💻 लाइव कोड एडिटर
इस पेज के प्रोग्राम यहीं तैयार हैं — चलाएँ, बदलें और सीखें। कुछ भी इंस्टॉल किए बिना।
OneCompiler द्वारा संचालित। कोड एडिटर में अपने आप आ जाता है — Run दबाकर आउटपुट देखें। अगर एडिटर न खुले तो नए टैब में खोलें.