Computer Science, asked by misscutie94, 6 months ago

WAP in C++ to input any number and to print whether the number is positive, negative or zero.
➡️ Wrong Answer will be reported​

Answers

Answered by Vyomsingh
37

Given:

  • WAP in C++ to input any number and to print whether the number is positive, negative or zero.

________________________

Logic Used:-

If n<0 Number is Negative .

if n>0 Number is positive.

else Number is 0.

________________________

Code:

  1. #include<iostream>
  2. using namespace std;
  3. int main ()
  4. {
  5. int n;
  6. cout << "Enter the number to be checked :";
  7. cin >> num;
  8. if (num > 0)
  9. cout << num << " is a positive number.";
  10. else if(num<0)
  11. cout << num << " is a negative number.";
  12. else
  13. cout << num << " is a Zero";
  14. return 0;
  15. }

________________________

Test 1→

Input:

Enter the number to be checked

46

Output:

46 is a positive number

Test 2→

Input:

Enter the number to be checked

-46

Output:

-46 is a negative number

Similar questions