首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include int f(int n) { int t = 0, a=5; if (n/2) {int a=6; t += a++; } else {int a=7; t += a++; } return t + a++; } main
有以下程序 #include int f(int n) { int t = 0, a=5; if (n/2) {int a=6; t += a++; } else {int a=7; t += a++; } return t + a++; } main
admin
2019-05-17
12
问题
有以下程序
#include
int f(int n)
{ int t = 0, a=5;
if (n/2) {int a=6; t += a++; }
else {int a=7; t += a++; }
return t + a++;
}
main()
{ int s=0, i=0;
for (; i<2;i++) s += f(i);
printf("%d\n", s);
}
程序运行后的输出结果是( )。
选项
A、24
B、28
C、32
D、36
答案
A
解析
一个源文件中如果外部变量和局部变量同名,则在该局部变量的作用域内,该外部变量会被"屏蔽",main()函数中调用两次f()函数,两次调用均进入else选择支句,t=7,返回7+5=12,所以s=0+f(0)+f(1)=24,答案选A。
转载请注明原文地址:https://jikaoti.com/ti/Qif0FFFM
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
若有定义typedefcharT[10];Tca;上述定义中a的类型与下面选项中完全相同的是
当变量c的值不为2、4、6时,值也为’’真’’的表达式是
以下叙述中正确的是
VN程序中函数f的功能是:当flag为1时,进行由小到大排序;当flag为0时,进行由大到小排序。yoidf(intb[],intn,intflag){inti,j,t;for(i=0;i<n-1;i++)for(j=i+lj<nj++)if(f
下列定义数组的语句中,正确的是
在一个C源程序文件中所定义的全局变量,其作用域为
以下叙述中正确的是
在满足实体完整性约束的条件下()。
以下不能用于描述算法的是
给定程序MODI1.C中函数fun的功能是:应用递归算法求形参a的平方根。求平方根的迭代公式如下:例如,a为2时,平方根值为:1.414214。请改正程序中的错误,使它能得出正确结果。注意:不要改动main函数,不得增行或删
随机试题
间接抗球蛋白试验检测何类抗体
(2006年)测量工作的基准线是()。
个人商用房贷款期限最长不超过()年。
国家助学贷款一般在()内还清。
把秋季集中产出的大米储存起来,起到稳定大米价格的功效,这是仓储的()。
公安机关对发现或者受理的案件暂时无法确定为刑事案件或者行政案件的,必须先按照刑事案件的程序办理。()
智力是创造力的充要条件。(2010年)
Facebookhasbeen【C1】______withfireandhasgotitsfingersburned,again.OnNovember29thAmerica’sFederalTradeCommission
WWW的超链接中定位信息所在位置使用的是______。
A、Tokeepfit.B、Tostudywell.C、Toearnmoremoney.D、Togainesteem.A事实细节题。短文开头提到,新年伊始是制订塑身计划的好时候,努力做一个身材匀称、健康快乐的人。
最新回复
(
0
)