본문 바로가기
C/c언어 수업

p280 나이입력 do while , switch

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

int main(void)
{
	int age;

	do {
		printf("how old r u?");
		scanf("%d", &age);
	} while (age<1);

	switch (age / 10)
	{
	case 0:
		printf("<10\n");
		break;
	case 1:
		printf("10<u<20\n");
		break;
	case 2:
		printf("20<=u<30\n");
		break;
	case 3:
		printf("30<=u<40\n");
		break;
	case 4:
		printf("40<=u<50\n");
		break;
	case 5:
		printf("50<=u<60\n");
		break;
	default:
		printf("60<u\n");
	
	}


	return 0;
}

'C > c언어 수업' 카테고리의 다른 글

p311 ascii  (0) 2020.08.06
p283 for, while  (0) 2020.08.05
p276 2와 3의 배수가 아닌 100 이하의 자연수들 - 소수 print  (0) 2020.08.05
p271 while 구구단  (0) 2020.08.05
p269 while  (0) 2020.08.05