Friday, May 15, 2020

C++ program that checks whether the No is Positive Negative and Zero

//Check No is negative,positive Or Zero


int n=10;
if(n<0)
{
cout<<"Negative\n";
}
else if(n>0)
{
cout<<"Positive\n";
}
else
{
cout<<"Zero\n";
}

This code is firsts checking the condition that whether our No is negative if it is negative then It will executes first part.You can use any no instead of 'n' or assign any value to 'n'. if first Condition is not true then our second part is going to check if our No is greater then zero then our second part is executed and print "positive" and If No is neither Positive Nor negative then our no is definitely zero so our Else part is going to executes and prints "Zero". 

No comments:

Post a Comment

Maximum No

//Find the Maximum No between Three Nos' int i=10,o=20,k=30; if(i>o &&i>k) { cout<<"1st is g\n";...