首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include <stdio.h> main() {int t; scanf("%d",&t); if(t++ <6)printf("%d\n",t); else printf("%d\n",t--);
有以下程序 #include <stdio.h> main() {int t; scanf("%d",&t); if(t++ <6)printf("%d\n",t); else printf("%d\n",t--);
admin
2022-04-01
96
问题
有以下程序
#include <stdio.h>
main()
{int t;
scanf("%d",&t);
if(t++ <6)printf("%d\n",t);
else printf("%d\n",t--);
printf("\n");
}
执行时输入:6 <回车>,则输出结果是( )。
选项
A、6
B、8
C、7
D、5
答案
C
解析
后置自增运算:t++表示先运算,后自加。if(t++ <6)printf("%d\n",t);else printf("%d\n",t--);t的初值为6,t++ <6,则条件为假,t自增至7,执行printf("%d\n",t--),此时t=7,打印t值为7,之后进行自减操作t=6。因此打印的结果为7。故答案为C选项。
转载请注明原文地址:https://kaotiyun.com/show/09kp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
有以下程序#include#includestructA{inta;charb[10];doublec;};structAf(structAt);main(){structAa={1001,"ZhangDa
有以下程序:#includedoublef(doubleX);main(){doublea=0;inti;for(i=0;i
有以下程序main(){chara[5][10]={"one","two","three","four","five"};inti,j;chart;for(i=0;i<4;i++)for(j=i+1;j<5;j++)
有以下程序#includemain(){inta=2,b;b=a
以下叙述中错误的是
有以下程序main(){inti,j;for(i=1;i
若a是数值类型,则逻辑表达式(a==1)‖(a!=1)的值是
有如下说明:intarray[10]={1,2,3,4,5,6,7,8,9,10},*p=array;则数值为9的表达式是________。
以下选项中,能正确进行字符串赋值的是
在C语言程序中,以下说法正确的是()。
随机试题
Nobodyhastaughthimhowtoactwellonthestage.
Whenpeoplearestruckbylightening,theyfalltothegroundasthoughtheywerestruckbyasevereblowtothehead.Afterthe
建设项目竣工环境保护验收是指建设项目竣工后,环境保护行政主管部门根据《建设项目竣工环境保护验收管理办法》规定,依据环境保护验收监测或调查结果,并通过()等手段,考核该建设项目是否达到环境保护要求的活动。
跟单员在处理样品时应注意的事项是()
某公司债券面值100元,票面利率为8%,每年付息,到期期限10年。如果将债券的利息单独作为证券出手,并且投资者要求的收益率为9%,那么该“利息证券”的发行价格为______。
张女士为A市甲超市财务管理人员,她从2014年1月份开始建立家庭消费电子账,6月份从甲超市购买了下列商品:(1)粉底液一盒,支出400元。(2)白酒1000克,支出640元。(3)食品支出1010元,其中:橄榄油2500克,支出400元;
马克思主义政治经济学的研究对象是社会生产力及其发展规律。
Myfive-year-olddaughterknewexactlywhatshewantedforChristmasof1977,andtoldmeso.Yes,shestillwouldlikethepink
Wheredoyoureallycomefrom?Andhowdidyouget(1)whereyoulivetoday?DNAstudiessuggestthatallhumanstoday(2)from
A、Callforadoctor.B、Buysomemedicine.C、LookforJack.D、SendJacktoschool.A根据对话中男士所说“Sure,I’lldoitrightaway.”可知男士马上要
最新回复
(
0
)