Write a program in C++ to check the number is positive or negative using Conditional Operator

#include <iostream.h>
#include <conio.h>

int main() {   
    int a;
        
    cout << "Enter a:";
    cin >> a;
    
    a>=0 ? cout<<"Positive" : cout<<"Negative";
      
    getch();
    return 0;
}

Output:

Leave a Reply

Contact Form

Name

Email *

Message *

Followers