C 간단한 예제 복리로 원금의 2배가 되는데 걸리는 시간을 구하는 예제. while 문이 이상함.
조회수 454회
int years = 0;
double rate, investment;
printf("원금 :");
scanf("%f", &investment);
printf("이율 :");
scanf("%f", &rate);
double total = investment;
while (total < investment * 2)
{
total = total * (1 + rate);
years += 1;
}
printf("%d년", years);
return 0;
왜 while 문 내에서 years 반복이 적용되서 출력이 안될까요?
-
(•́ ✖ •̀)
알 수 없는 사용자 - 〉
댓글 입력