
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
Using conditional statement check the number with 0 weather it is greater than 0 or smaller than 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;
}以上就是C程序检查一个数是正数还是负数还是零?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号