Q: Write a program to check whether the given number is positive or negative (using ? : ternary operator )
Solution:
Screenshot:
Solution:
#include <iostream> using namespace std; int main(int argc, char *argv[]) { int a; cout<<"Enter any non-zero Number : "; cin>>a; (a>0)?cout<<"Number is positive":cout<<"Number is negative"; return 0; }
Screenshot:
No comments:
Post a Comment