write a C program to check whether an input number is less than, greater than or equal to zero.
Answers
Answered by
1
Program :
#include <iostream>
using namespace std;
int main() {
int n=0;
if(n>0) {
printf("%d is positive",n);
} else if(n<0) {
printf("%d is negative",n);
} else {
printf("%d is zero",n);
}
return 0;
}
Explanation :
Using conditional statement check the number with 0 weather it is greater than 0 or smaller than 0.
A number which is greater than 0 is positive and less than 0 are negative. The concept of positive and negative is very important in number theory and programming also. Calculations rely on this concept only.
Input: 0
Output:0 is zero
Similar questions
Science,
2 months ago
Math,
2 months ago
Social Sciences,
4 months ago
Social Sciences,
10 months ago
Chemistry,
10 months ago
Social Sciences,
10 months ago