fork download
  1. //This code is for checking if number is positive or not
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main() {
  7. int num ;
  8. // Take input from user to check
  9. cout<< "Enter a number of your choice:!\n " <<endl;
  10. cin>> num;
  11.  
  12. //check if number is greater than 0 then it is positive else negative
  13. if(num > 0)
  14. cout<<"Entered number is positive number!!";
  15. else
  16. cout<<"Number is not positive, re enter the number as only positive numbers are allowed!";
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 5292KB
stdin
7
stdout
Enter a number of your choice:!
 
Entered number is positive number!!