下列程序的输出结果是( )。 #include<stdio.h> f(int A) {intb=0; staticint c=4; a=c++;b++; retum(A) ; } main() {int a==2,i,c; for(i=0;i<2;i++) C=f(a++); printf("%dhn",C) ; }
A.4
B.7
C.6
D.5
参考答案:D
解析: 本题考查静态变量的使用方法和for循环。在函数调用时,static变量在函数调用结束后所作的所有变化均不保持,所以当i-1时,第2次进入f函数时c=5,所以最终main函数中c的值为5。