C/C++
비주얼 스튜디오 C언어 복리계산 예제 문제 질문드립니다.

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
	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;
}

현재 이렇게까지는 만들었는데 years가 반복문에서 작동하지 않는 것 같고, 값에 상관없이 변수선언한대로 0년으로 출력됩니다. 이제 막 배우는 단계라 초보적인 질문 죄송합니다.

힌트라도 주시면 연구해보겠습니다..

댓글 1