0
Input a number and check whether it is positive ,negative or zero
c++program
4 Respostas
+ 1
PLEASE! Show your attempt first. You should done your work yourself and we are only here to support you. Otherwise you won't be able to become a professional coder
+ 1
A clue to solve this is to create different conditions to check if a number entered is any of the following: positive, negative, zero.
When is a number considered positive? Negative? This is basic math. You can do it. ;-)
+ 1
#include<iostream>
using name space std;
int main()
{
int num;
cout<<"enter a number\n";
cin>>num;
if(num>0)
cout<<num<<"is positive";
elseif(num<0)
cout<<num<<"is negative";
else
cout <<num<<"is zero";
return(0);
}
+ 1
Just minor corrections:
using namespace std;
else if (num < 0)