Using if...else if statement, make a program that will ask a number and determine if the inputted number is "positive", "negative", or "zero" c++
SOLUTION CODE
#include<iostream>
using namespace std;
int main(){
//propmt the user for a number
int number;
cout<<"Enter a number : ";
cin>>number;
if(number == 0)
{
cout<<"The input number "<<number<<" is a zero"<<endl;
}
else if(number>0)
{
cout<<"The input number "<<number<<" is a positive"<<endl;
}
else
{
cout<<"The input number "<<number<<" is a negative"<<endl;
}
return 0;
}
Comments
Leave a comment