/* */ Click to Join Live Class with Shankar sir Call 9798158723

If else statement in C++

In If Statement the statement is executed when the condition is true otherwise statement will be skips. Means that when we want to execute some other block of code if the condition is false.we can use the if else statement in C++. it menas that when the condition was true it execute IF block otherwish executed Else block when the condition is false.

Syntex :-

        // if condition is true then if statement is executed.
        //if condition is flase then Else statement is executed

Q.) W.A.P to o check whether an integer is positive or negative. ?
    // Program to check whether an integer is positive or negative
// This program considers 0 as a positive number

#include < iostream>
using namespace std;

int main() {

  int number;

  cout << "Enter an integer: ";
  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 printed.";

  return 0;
Enter an integer: 4
You entered a positive integer: 4.
This line is always printed.