본문 바로가기
C and C++

[C Examples] 적금 계산기

by Henry Cho 2023. 1. 31.
728x90

적금 계산기

포스트 난이도: HOO_Intern


# Example codes

 

#include <stdio.h>
#include <stdlib.h>

int main()
{
   float A, r;
   int P, t;
   
   printf("Enter inital balance\n");
   scanf("%d", &P);
   printf("Enter Annual interest rate\n");
   scanf("%f", &r);
   printf("Enter how many years\n");
   scanf("%d", &t);
   
   A=P*(1+r*t);
   printf("The balance after %d years will be (%.2f $)\n", t, A);
   printf("Posted by HOO.");
    return 0;
}

Enter inital balance
3000
Enter Annual interest rate
2.5
Enter how many years
5
The balance after 5 years will be (40500.00 $)
Posted by HOO.

 

728x90

댓글