• C++ Language

    Simple If Statement

    In simple if statement the line of code inside if statement are executed if the condition or expression is true. Syntax if (Expression or Condition) { // statements } Example #include <iostream> using namespace std; int main() { int number; cout << "Enter an integer: "; cin >> number; //if number is positive then statements inside if statements are executed. if ( number > 0) { cout << "You entered a positive integer: " << number << endl; } cout << "This statement is always executed."; return 0; } OutPut Enter an integer: 5 You entered a positive number: 5…

  • C language

    Simple if 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 Statement Are Executed } //Outside Statement Are Executed Here, If  the expression evaluated as true then inside statements are executed, otherwise outside statements are executed. If the if block has only one statement then there is no need to put curly braces {}, but if the if block has more then one statement then it must put curly braces. Example is…