top of page

If Statement क्या है?

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

If statement एक control structure है जो प्रोग्राम को condition के आधार पर decision लेने की क्षमता देता है। इसमें कोई condition दी जाती है, और अगर वह condition true होती है तो if के अंदर वाला code block execute होता है, अन्यथा skip कर दिया जाता है।


Syntax:

if (condition) {   // Code executed when condition is true }


Working:

  • Condition को evaluate किया जाता है।

  • अगर condition true है, तो अंदर का code चलता है।

  • अगर condition false है, तो if block का code ignore कर दिया जाता है।


Example:

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

इस example में, अगर age 18 या उससे ज्यादा है, तो message print होगा, अन्यथा कुछ नहीं होगा।


Flow-Chart of if
Flow-Chart of if

उपयोग:

  • Simple decision-making के लिए।

  • किसी specific condition पर ही program का कोई हिस्सा run कराने के लिए।

If statement से प्रोग्राम के decision making में flexibility आती है, जिससे प्रोग्राम user input, data validation, या other conditions के अनुसार अलग-अलग रास्ते अपना सकता है।

 
 
 

Comments


bottom of page