Pages

Friday, July 21, 2017

if-else statement in C++

C++ program to check given number is positive or not using if..else statement.


#include<iostream>
using namespace std;
int main()
{
  int number;

  cout << "Enter number:";
  cin >> number;

  if(number > 0)
      cout << "Number is positive.";
  else
      cout << "Number is not positive.";
  return 0;
}

Output of the program

Enter number:11
Number is positive.

1 comment: