Số > 0 là dương, < 0 là âm. Khái niệm này quan trọng trong lý thuyết số và lập trình.
Input: 0 Output:0 is zero
Giải thích
Dùng câu lệnh điều kiện so sánh số với 0: lớn hơn, nhỏ hơn, hoặc bằng 0.
Ví dụ
#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;
}