FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 57   



Following program shows you how to take a number as input and tells its positive or negative.
In this program we get number from user, and if the number is less than zero it prints negative, and if the number is grater than zero it prints positive

#include <iostream>

int main() {
    int i;
    std::cout << "Enter a number:";
    std::cin >> i;

    if (i < 0) {
        std::cout << "given number is -ve";

    } else {
        std::cout << "given number is +ve";
    }
}

Output:

Example1:

Enter a number: 9
given number is +ve

Example2:

Enter a number: -2
given number is -ve



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News