편집 기록

편집 기록
  • 프로필 nowp님의 편집
    날짜2021.12.01

    C 간단한 예제 복리로 원금의 2배가 되는데 걸리는 시간을 구하는 예제. while 문이 이상함.


    이미지

    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 반복이 적용되서 출력이 안될까요?

  • 프로필 알 수 없는 사용자님의 편집
    날짜2021.11.30

    간단한 예제 문제 질문 (c언어)


    이미지

    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 반복이 적용되서 출력이 안될까요 ㅜㅜ 
    
  • 프로필 nowp님의 편집
    날짜2021.11.30

    간단한 예제 문제 질문 (c언어)


    이미지

    #define _CRT_SECURE_NO_WARNINGS
    #include <stdio.h>
    int main(void)
    {
        int years;
        double rate, investment;
    
        printf("원금 :");
        scanf("%f", &investment);
        printf("이율 :");
        scanf("%f", &rate);
    
        double total = investment;
    
        for (years = 1;total = investment * 2;years++)
        {
            total = total * (1 + rate);
            printf("%d년", years);
        }
        return 0;
    }
    

    for 문 탈출이 안되는데 어떻게 해야할지 알 수 있을까요?

  • 프로필 알 수 없는 사용자님의 편집
    날짜2021.11.30

    간단한 예제 문제 질문 (c언어)


    이미지

    define _CRT_SECURE_NO_WARNINGS

    include

    int main(void) { int years; double rate, investment;

    printf("원금 :");
    scanf("%f", &investment);
    printf("이율 :");
    scanf("%f", &rate);
    
    double total = investment;
    
    for (years = 1;total = investment * 2;years++)
    {
        total = total * (1 + rate);
        printf("%d년", years);
    }
    return 0;
    

    }

    for 문 탈출이 안되는데 어떻게 해야할지 알 수 있을까요 ㅜ