• 카테고리

    질문 & 답변
  • 세부 분야

    프로그래밍 언어

  • 해결 여부

    미해결

똑같이 쳤는데, 아무런 것도 출력이 되지 않습니다! printf도 확실하게 쳤습니다!

22.03.22 03:05 작성 조회수 102

0

#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> int main() { double seed_money, target_money, annual_interest; printf("Input seed money : "); scanf("%lf", &seed_money); // double이라서 lf 사용!! printf("Input target money : "); scanf("%lf", &target_money); printf("Input annual interest (%%) : "); // % 기호 출력 %% scanf("%lf", &annual_interest); double fund = seed_money; int year_count = 0; while (fund < target_money); { //fund = fund + fund * annual_interest / 100.0; fund += fund * annual_interest / 100.0; //year_count = year_count + 1; //year_count += 1; year_count++; printf("Year %d, fund %f\n", year_count, fund); } printf("It takes %d years\n", year_count); return 0; }
 
 
이렇게 작성을 하였습니다. 세 가지(seed target annual)입력하고 나서 줄바뀜이 일어나고 아무런 것들도 출력이 일어나지 않는데 이건 무슨 현상일까요??
콘솔창에 타자를 쳐도 아무것도 안쳐지고, 타자를 치는 부분을 의미하는 하얀색 네모가 계속 껌뻑거리고만 있습니다...!

답변 1

답변을 작성해보세요.

1

강민철님의 프로필

강민철

2022.03.22

안녕하세요

 

while (fund < target_money);

 

에 붙어있는 ; 때문입니다. 오타인 듯 하네요.

위와 같이 ;가 붙어 있다면 무한 루프를 돌게 됩니다.