首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下面程序的输出结果是( )。 func(int X) { static int a=2; return (a+=X);} main() { int b=2,c=4,d; d=func(b); d=func(
下面程序的输出结果是( )。 func(int X) { static int a=2; return (a+=X);} main() { int b=2,c=4,d; d=func(b); d=func(
admin
2009-04-15
20
问题
下面程序的输出结果是( )。 func(int X) { static int a=2; return (a+=X);} main() { int b=2,c=4,d; d=func(b); d=func(c); printf("%d\n",d); }
选项
A、4
B、6
C、8
D、12
答案
4
解析
func(b)调用函数func并将实参传递给形参x,x的值为2。a+=x=2+2=4,返回值为4。func(c)调用函数func并将实参传递给形参x,x的值为4。因为a被定义为静态的整型变量,当第一次调用函数func返回后a存储单元中的数据仍然保留值为4,所以a+=x=4+4=8。
转载请注明原文地址:https://kaotiyun.com/show/5sWp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
窗体上有一个名称为Text1的文本框,一个名称为Command1的命令按钮。要求编写一个程序,统计文本框中0-9各数字字符的个数。某人编写如下程序:PrivateSubCommand1_Click()Dimcount(10)AsInt
以下关于VB的叙述中,错误的是
在考生文件夹中有一个工程文件sjt5.vbp。该程序的功能是从in5.瞰文件中读入40个数据,统计这些数据中素数的个数,并找出所有素数中最小的素数(判断素数的函数已给出)。最后将查找和统计的结果分别显示在标签Labe14和Labe13中(窗体外观如图所示)
以下关于函数过程的叙述中,正确的是( )。
下面是求最大公约数的函数的首部()。Functionfun(ByValxAsInteger,ByValYAsInteger)AsInteger若要输出8、12、16这3个数的最大公约数,下面正确的语句
若实体A和B是一对多的联系,实体B和C是一对一的联系,则实体A和C的联系是
一棵二叉树中共有80个叶子结点与70个度为1的结点,则该二叉树中的总结点数为
以下关系表达式中,其值为True的是( )。
问题处理方案的正确而完整的描述称为______。
随机试题
双向沟通
实验组、控制组前后测设计的基本模式是()
服用洋地黄药物期间应禁忌使用()
工程咨询单位由()办理资格认定工作。
学校社区工作包括哪些工作内容?( )
有人认为,任何一个机构都包括不同的职位等级或层级,每个人都隶属于其中一个层次。如果某人在原来级别岗位上干得出色,就会被提拔,而被提拔者得到重用后却碌碌无为,这会造成机构效率低下,人浮于事。以下哪项为真,最能质疑上述观点?
下列叙述中正确的是()。
Wheredoestheconversationmostprobablytakeplace?
Humour,whichoughttogiverisetoonlythemostlight-heartedandgayfeelings,canoftenstirupvehemenceandanimosity.Evi
Idon’tfeellikeswimmingintheseatoday,I’dratherlieonthe______.
最新回复
(
0
)