首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include int fun() { static int x=1; x*=2; return x; } main() { int i,s=1; for(i=1;i
有以下程序 #include int fun() { static int x=1; x*=2; return x; } main() { int i,s=1; for(i=1;i
admin
2016-12-28
24
问题
有以下程序
#include
int fun() {
static int x=1;
x*=2;
return x; }
main() {
int i,s=1;
for(i=1;i<=3 ; i++)
s*=fun();
printf("%d\n",s);}
程序运行后的输出结果是
选项
A、0
B、10
C、30
D、64
答案
D
解析
本题考查了静态局部变量,该局部变量的值在函数调用结束后如果不消失而保留原值。函数fun的功能返回2的乘方,主函数fun函数调用3次,因此第一次s累乘2,第二次累乘4,第三次累乘8,即为2*4*8,值为64。
转载请注明原文地址:https://kaotiyun.com/show/yrDp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
有以下程序intf(intn){if(n==1)return1;elsereturnf(n-1)+1;}main(){inti,j=0;for(i=1;i
有以下程序main(){intk=5,n=0;do{switch(k){case1:case3:n+=1;k--;break;default:n=0;k--;case2:case
若函数调用时的实参为变量时,以下关于函数形参和实参的叙述中正确的是______。
若变量均已正确定义并赋值,以下合法的C语言赋值语句是______。
下列选项中,值为1的表达式是()。
若有下列说明和语句,则对结构体变量st中成员i的引用方式不正确的是()。Structstu{inti;intname;}st,*p;p=&st;
下列选项中,当x为大于1的奇数时,值为0的表达式是()。
有下列程序:main(){intx=5;do{printf("%d",x-=4);}while(!(--X));}程序的输出结果是()。
下列选项中,不是一个算法的基本特征的是()。
mystrlen函数的功能是计算str所指字符串的长度,并作为函数值返回。请填空。intmystrlen(char*str){intI;for(I=0;【】!=’\n’;I++);return(I);}
随机试题
使用旺火、短时间加热的烹调方法,应将原料尽量_______,使其在短时间内吸收大量能量,迅速成熟,并保持足够的水分。
大功率起动机上多采用单向滚柱式离合器。()
电器着火,在未切断电源时只能用()灭火器灭火。
TCP/IP协议实际上是一组协议,是一个完整的体系结构。
勘测定界中的土地分类明细表(征用表)采用()土地分类。
我国2004年实施的《道路交通安全法》规定的残疾人机动轮椅车行驶的最高时速是()km。
根据优化目标的不同,网络计划的优化可分为()。
建设项目可能产生环境噪声污染的,建设单位必须提出环境影响报告书,环境影响报告书中,应当有()的意见。
下列说法正确的是()。
人们普遍认为适量的体育运动能够有效降低中风的发生率,但科学家还注意到有些化学物质也有降低中风风险的效用。番茄红素是一种让番茄、辣椒、西瓜和番木瓜等果蔬呈现红色的化学物质。研究人员选取一千余名年龄在46至55岁之间的人,进行了长达12年的跟踪调查,发现其中番
最新回复
(
0
)