🟡 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

  • if runs a block when its condition is true.
  • else if adds choices; else is 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

सारांश

  • if condition true होने पर block चलाता है।
  • else if choices जोड़ता है; else fallback है।
← Back to Java Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

\n