Friday, October 28, 2016

C++(check Positive or Negative)

9
-Write a program to check whether the given number is positive or negative  (using ? : ternary operator ) 

#include<iostream.h>
#include<conio.h>
 
int main()
{
      int a;
      cout<<"Enter any non-zero Number : ";
      cin>>a;
      (a>0)?cout<<"Number is positive":cout<<"Number is negative";
 
      getch();
      return 0;
}

No comments:

Post a Comment