首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
若有以下程序 #include <stdio.h> main() { int a=1,b=2,c=3,d=4, r=0; if (a!=1) ; else r=1; if (b==2) r+=2
若有以下程序 #include <stdio.h> main() { int a=1,b=2,c=3,d=4, r=0; if (a!=1) ; else r=1; if (b==2) r+=2
admin
2021-06-15
29
问题
若有以下程序
#include <stdio.h>
main()
{ int a=1,b=2,c=3,d=4, r=0;
if (a!=1) ; else r=1;
if (b==2) r+=2;
if (c!=3); r+=3;
if (d==4) r+=4;
printf("%d\n", r);
}
则程序的输出结果是
选项
A、3
B、7
C、6
D、10
答案
D
解析
第一个if语句a!=1条件为假,所以执行else后的语句r=1,第二个if语句b==2条件成立,执行r+=2,r的值变为3,第三个if语句c!=3条件为假,所以不做任何操作,执行下面的r+=3操作,r的值变为6,判断第四个if条件,d==4条件成立,执行r+=4操作,结果为10。
转载请注明原文地址:https://kaotiyun.com/show/h8tp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
以下选项中合法的标识符是
有以下程序(strcpy为字符串复制函数,strcat为字符串连接函数)#include#includemain(){chara[10]="abc",b[10]="012",c[10]="xyz";str
若变量均已正确定义并赋值,以下合法的C语言赋值语句是()。
有以下程序#includemain(){inti=5;do{if(i%3==1)if(i%5==2){printf("*%d",i);break;}i++;}while(i!=0);printf("
以下叙述中正确的是()。
以下叙述中正确的是
若有定义语句:doublex,y,*px,*py;执行px=&x;py=&y;正确的输入语句是
软件测试用例包括
算法的有穷性是指()。
随机试题
OnOctober31st,dozensofchildrendressedincostumes(节日服装)knockontheirneighbors’doorsandyell"TrickorTreat"whenthe
关于肾病综合征的一般治疗,错误的是
可用于测量肾血浆流量的物质是
在牙合堤上画出的口角线为
患者,女,40岁。头昏、乏力半年,近2年每次月经经期持续7~8天,有血块。红细胞3.0×1012/L,血红蛋白65g/L,血清铁蛋白10μg/L,血清叶酸16ng/ml,网织红细胞0.015。该病人最可能的诊断是
病人可能面临的危机有哪些?( )
从所给的四个选项中,选择最合适的一个填入问号处,使之呈现一定的规律性。
甲与国有公司仓库保管员乙合谋后,由甲在乙值班时将库存物资运出。销赃所得3万元由二人平分。在本案中()(2010年一专一第16题)
Lastnight,itwasstilllightoutwhenIreturnedhomefromwork.Mynewneighborandhissonwereintheir【C1】______place,out
BigisBackA)Corporategiantswereonthedefensivefordecades.Nowtheyhavetheadvantageagain.In1996,inoneofhis
最新回复
(
0
)