C
posZeroNeg
호타리
2023. 9. 1. 12:16
#include <stdio.h>
int main(void)
{
int num;
scanf("%d", &num);
if (num > 0)
{
printf("%d is a positive number\n", num);
}
else if (num == 0)
{
printf("%d is zero number\n", num);
}
else
{
printf("%d is a negative number\n", num);
}
return 0;
}
#include <stdio.h>
int main(void)
{
int num;
scanf("%d", &num);
/*
if (num > 0)
{
printf("%d is a positive number\n", num);
}
else if (num == 0)
{
printf("%d is zero number\n", num);
}
else
{
printf("%d is a negative number\n", num);
}
*/
printf("%d is a %s num\n", num, (num > 0) ? "positive" : (num == 0) ? "zero" : "negative");
return 0;
}
<compile 결과>
