C출력 결과보통 · 20점#구조체#포인터#서식 문자

200. 구조체 포인터로 복리 잔액 계산

다음 C 프로그램의 실행 결과를 쓰시오.

1#include <stdio.h>
2
3struct Acct {
4 int year;
5 double bal;
6};
7
8void grow(struct Acct *a, double rate) {
9 a->bal = a->bal * (1 + rate);
10 a->year++;
11}
12
13int main() {
14 struct Acct ac = {0, 800.0};
15 for (int i = 0; i < 3; i++) {
16 grow(&ac, 0.25);
17 }
18 printf("%d %.2f\n", ac.year, ac.bal);
19 return 0;
20}

해설을 먼저 보면 이후 정답 시 점수가 50%만 반영됩니다.