单项选择题

有以下程序:
#include<stdio.h>
int f(int n);
main()
{ int a=3, s;
s=f(a); s=s+f(a); printf("%d\n", s);
}
int f(int n)
{ static int a=1;
n+=a++;
return n;
}
程序运行后的输出结果是______。

A.7
B.8
C.9
D.10
<上一题 目录 下一题>
热门 试题

单项选择题
设有以下函数:void fun(int n, char*s){…}则下面对函数指针的定义和赋值均正确的是______。
A.void(*pf)(); pf=fun;
B.void*pf(); pf=fun
C.void*pf(); *pf=fun;
D.void(*pf)(int, char); pf=&fun;
单项选择题
以下函数findmax拟实现在数组中查找最大值并作为函数值返回,但程序中有错导致不能实现预定功能。#define MIN-2147483647int findmax(int x[], int n){ int i, max;for(i=0; i<n; i++){ max=MIN;if(max<x[i])max=x[i];}return max;}造成错误的原因是______。
A.定义语句“int i, max;”中max未赋初值
B.赋值语句“max=MIN;”中,不应给max赋MIN值
C.语句“if(max<x[i])max=x[i];”中判断条件设置错误
D.赋值语句“max=MIN;”放错了位置
相关试题
  • 以下叙述中正确的是______。
  • 若有以下程序段:int r=8;print( %d...
  • 有以下程序:#include<stdio.h>#inclu...
  • 设有定义:“char*c;”,以下选项中能够...
  • 设有定义:“int a=1, b=2, c=3...