본문 바로가기
???

???p236 if (!(num % 2))even / odd // negative/ positive num

by sj0020 2020. 8. 5.
#include <stdio.h>

int main(void)
{
	int num;

	printf("enter int : ");
	scanf("%d", &num);

	if (!(num % 2)) /*if((n%2)==0와 동일*/
		printf("even number\n");
	else
		printf("odd num.\n");

	if (num < 0)
	{
		printf("and negative num.\n");
	}
	else
	{
		if (num == 0)
			printf("zero.\n");
		else
			printf("and positive num.\n");
	}
	return 0;
}