• C++ Language

    If…Else Statement In C++

    In if…else statement, if the condition is true then the statements inside if statements are executed, and if the condition is false then statements inside else are executed. Syntax if(Condition or Expression) { //Statements } else { //Statements } Example #include <iostream> using namespace std; int main() { int number; cout << "Enter an integer value: "; cin >> number; if ( number >= 0) { cout << "You entered a positive integer: " << number << endl; } else { cout << "You entered a negative integer: " << number << endl; } cout << "This line is always…

  • C language

    if…else Statement In C

    Decision making with if statement may be implemented in different forms depending on the complexity of conditions to be tested.The different forms are, Simple if statement if….else statement Nested if….else statement Using else if statement Syntax if(expression) { //Inside if Statement Are Executed } else { //Inside else Statement Are Executed } //Outside if...else block Statement Are Executed Here, if the expression is true then if block statements are executed and after it directly outside if…else block statements are executed, otherwise else block statements are executed and after it directly outside if…else block statements are executed. It means if expression…