Menu Close

判断正负数 – 分支结构



void main()
{
   int num;

   printf("Enter a number: \n");
   scanf("%d", &num);
   if (num > 0)
   printf("%d is a positive number \n", num);
   else if (num < 0)
   printf("%d is a negative number \n", num);
   else
   printf("0 is neither positive nor negative");
}

结果

Enter a number:
-3
-3 is a negative number
除教程外,本网站大部分文章来自互联网,如果有内容冒犯到你,请联系我们删除!

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

Leave the field below empty!

Posted in C语言习题集

Related Posts