首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序: #include<stdio.h> int f(int n); void main() { int a=3,s; s=f(a);s=s+f(a); printf("%d\n",s);
有以下程序: #include<stdio.h> int f(int n); void main() { int a=3,s; s=f(a);s=s+f(a); printf("%d\n",s);
admin
2013-10-14
81
问题
有以下程序:
#include<stdio.h>
int f(int n);
void 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:
}
程序运行后的输出结果是( )。【09年9月】
选项
A、7
B、8
C、9
D、10
答案
C
解析
在主函数中第一次调用f(a)时,得到变量s的值等于4,在第二次调用f(a)时,在子函数f中由于变量a是一个局部静态变量,所以这次其值等于2,因而在主函数中第二次调用f(a)后,其返回值等于5,最后变量s的值等于9。
转载请注明原文地址:https://kaotiyun.com/show/e0Jp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
有以下程序 #include <stdio.h> int fun(int (*s)[4],int n,int k) {int m,i; m=s[0][kl; for(i=1;i<n;i++) if(s[i]
若有定义语句:double x[5]={1.0,2.0,3.0,4.0,5.0},*p=x;则错误引用x数组元素的是______。
下列程序的运行结果为【】。#include<stdio.h>#include<string.h>{inta;charb[10];doublec;};voidf(str
以下程序用来判断指定文件是否能正常打开,请填空。#include<stdio.h>main(){FILE*fp;if(((fp=fopen("test.txt","r"))=【】))
有以下程序#include<stdio.h>inttb=2;intfun(int*k){b=*k+b;return(b);}main(){inta[
设变量已正确定义,以下不能统计出一行中输入字符个数(不包含回车符)的程序段是______。
阅读以下函数fun(char*s1,char*s2){inti=0;while(s1[i]==s2[i]&&s2[i]!=’\0’)i++;return(s1[i]==’\0’&&s2[i]==’\0’
以下函数的功能是:通过键盘输入数据,为数组中的所有元素赋值。#defineN10voidartin(intx[N]){inti=0;while(i<N)scanf("%d",);
下列条件语句中,功能与其他语句不同的是()。
设有以下语句:chara=3,b=6,C;c=a|b<<2;printf("%d\n",C);则c的二进制值是()。
随机试题
应选用何种浓度的磷酸进行酸蚀操作过程中哪一项不正确
全国银行间市场债券托管账户是以( )的名义开立的。
Whenweconductforeigntrade,theimportanceofunderstandingthelanguageofacountrycannotbeunderestimated.Thesuccessfu
设,xn=xn-1+un,n=1,2,…,且u0=x0=1.证明xn存在。
下面程序错误的语句是①#include<iostream.h>②voidmain(0③{④int*p=newint[1];⑤p=9;⑥cout<<*p<<end1;
在关系运算中,查找满足一定条件的元组的运算称之为【】。
AmericanLiteratureAliteratureistherecordofhumanexperienceandpeoplehavealwaysbeenimpelledtowritedowntheirimpr
ThefirstmentionofslaveryinthestatutesoftheEnglishcoloniesofNorthAmericadoesnotoccuruntilafter1660—somefor
Excessivesugarhasastrongmal-effectonthefunctioningofactiveo【66】suchastheheart,kidneysandthebrain.Shipwrecked
A、Thesupermarketistoocrowded.B、Therearemanysupermarketshere.C、Look,justoverthere.D、Itiseleveno’clock.C本题问的是最近
最新回复
(
0
)