«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
관리 메뉴

printf("ho_tari\n");

posZeroNeg 본문

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 결과>

'C' 카테고리의 다른 글

exponent practice  (0) 2023.09.01
power  (0) 2023.09.01
pointerAndArray2  (0) 2023.09.01
pointerAndArray  (0) 2023.09.01
pointer6  (0) 2023.09.01