用来检查数字是正数还是负数或零的C程序?

大于0的数字为正,小于0的数字为负。正数和负数的概念在数论和程序设计中也非常重要。计算仅基于此概念。

Input: 0
Output:0 is zero

说明

使用条件语句检查天气为0的数字大于0或小于0。

示例

#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;
}