top of page

if-else Statement क्या है?

  • Writer: Siddharth Sharma
    Siddharth Sharma
  • Oct 7, 2025
  • 1 min read

if-else statement एक control structure है जो decision making को दो विकल्प देता है। इसमें condition evaluate की जाती है, और अगर वह true होती है तो if block का code execute होता है, अन्यथा else block का code चलता है।


Syntax:

if (condition) {   // condition true होने पर यह code चलेगा } else {   // condition false होने पर यह code चलेगा }

काम करने का तरीका:

  • Program सबसे पहले condition check करता है।

  • अगर condition true है, तो if block execute होता है।

  • अगर condition false है, तो else block execute होता है।


Example:

int age = 20;
if (age >= 18) {
  printf("You are eligible to vote.");
} else {
  printf("You are not eligible to vote.");
}

यहाँ, अगर उम्र 18 या उससे अधिक है तो वोट के लिए योग्य बताया जाएगा, अन्यथा असमर्थ बताया जाएगा।


if-else Statement flow chart
if-else Statement flow chart

उपयोग:

  • जब दो विकल्पों में से किसी एक को चुनना हो।

  • program को flexible decision-making की क्षमता देना।

if-else statement program flow control को आसान और स्पष्ट बनाता है, जिससे conditions के आधार पर अलग-अलग actions लिए जा सकते हैं.

 
 
 

Comments


bottom of page