본문 바로가기
C and C++/C and C++ Examples

[C Examples] 도시의 인구 수 예측하기, 예제코드: scanf(), putchar()

by Henry Cho 2023. 1. 30.
728x90

도시의 인구 수 예측하기, 예제코드: scanf(), putchar()

포스트 난이도: HOO_Intern


# Example Codes

 

#include <stdio.h>

int main()
{
    double hooPopulation;
    int t;
    printf("Enter a year after 2022>");
    putchar ('\n');
    
    scanf("%d",&t);
    hooPopulation = 88.732+(5.889*(t-2022));
    
    printf("Predicted HOO City population for %d (in thousands): ",t);
    putchar ('\n');
    
    printf("%.5f",hooPopulation);
    putchar ('\n');
    
    printf("Posted by HOO");

    return 0;
}

Enter a year after 2022>
2030
Predicted HOO City population for 2030 (in thousands): 
135.84400
Posted by HOO

 


 

728x90

댓글