<프로그램 1>에서 <프로그램 3>까지 순차적으로 실행하였을 때 출력되는 결과로 옳은 것은?
<프로그램 1> | ||
#include <stdio.h>
int func() {
static int x = 10;
return x += 10;
}
void main() {
int x;
x = func();
x = func();
printf("a = %d\n", x);
} | ||
<프로그램 2> | ||
#include <stdio.h>
int x = 10;
void func() {
x += 10;
}
void main() {
int x = 10;
func();
func();
printf("b = %d\n", x);
} | ||
<프로그램 3> | ||
#include <stdio.h>
int x = 10;
void func() {
x += 10;
}
void main() {
func();
func();
printf("c = %d\n", x);
} | ||
- ①a = 10
- ②a = 10b = 30 b = 30c = 10 c = 30
- ③a = 30
- ④a = 30b = 10 b = 30c = 30 c = 30
선지를 골라 바로 채점해 보세요.
정답 ③
출처: 인사혁신처 공개 기출(공공데이터포털, 이용허락 제한 없음)