0

Input a number and check whether it is positive ,negative or zero

c++program

18th Feb 2019, 4:13 PM
Amala Malu Thomas
Amala Malu Thomas - avatar
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
18th Feb 2019, 4:17 PM
Seniru
Seniru - avatar
+ 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. ;-)
18th Feb 2019, 5:04 PM
Lambda_Driver
Lambda_Driver - avatar
+ 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); }
18th Feb 2019, 11:50 PM
Amala Malu Thomas
Amala Malu Thomas - avatar
+ 1
Just minor corrections: using namespace std; else if (num < 0)
19th Feb 2019, 4:02 AM
Lambda_Driver
Lambda_Driver - avatar