2022. 2. 11. 13:16ㆍ과제 업로드
/*
다음 입력과 출력을 하시오.
while 문과 if 문 사용
출력화면
숫자를 입력하시오 => 입력 100을 합니다.
100과 같습니다.
숫자를 입력하시오 => 입력 101을 합니다.
100 보다 큽니다.
숫자를 입력하시오 => 입력 99을 합니다.
100보다 작습니다.
숫자를 입력하시오 => 0
프로그램 종료
*/
#include
int main()
{
while (1)
{
int user_input;
printf("숫자를 입력하시오:");
scanf_s("%d", &user_input);
if (user_input == 0)
{
printf("프로그램 종료\n");
break;
}
if (user_input == 100)
{
printf("100과 같습니다.\n");
}
if (user_input >100)
{
printf("100보다 큽니다.\n");
}
if (user_input < 100)
{
printf("100보다 작습니다.\n");
}
}
//else if 로 구현한 코드입니다.
/*while (1)
{
printf("숫자를 입력하시오:");
scanf_s("%d", &user_input);
if (user_input == 100)
{
printf("100과 같습니다.\n");
}
else if (user_input > 100)
{
printf("100보다 큽니다.\n");
}
else if (user_input<100 && user_input>0)
{
printf("100보다 작습니다.\n");
}
else if (user_input == 0)
{
printf("프로그램 종료\n");
break;
}
else
{
printf("Error\n");
break;
}
}*/
return 0;
}
'과제 업로드' 카테고리의 다른 글
2022. 02. 10 if문 (if_3) (0) | 2022.02.14 |
---|---|
2022. 02. 11 if문 (if_2) (0) | 2022.02.14 |
2022.02.09 문자 비교 문제(opExam_3) (0) | 2022.02.11 |
2022.02.09 scanf문제 (0) | 2022.02.09 |
2022.02.09 형식지정_제어문자 문제 (0) | 2022.02.09 |