首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
阅读下面的程序: #include<iostream.h> void main() { int x; cin>>x; if(x++>5) cout<<x<<end1; else cout<<x--<<e
阅读下面的程序: #include<iostream.h> void main() { int x; cin>>x; if(x++>5) cout<<x<<end1; else cout<<x--<<e
admin
2012-01-20
15
问题
阅读下面的程序: #include<iostream.h> void main() { int x; cin>>x; if(x++>5) cout<<x<<end1; else cout<<x--<<end1; } 如果两次执行上述程序,且键盘输入分别为4和6,则输出结果分别是( )。
选项
A、4,6
B、3,6
C、4,7
D、5,7
答案
D
解析
此题首先读入数值4赋给变量x,因为x++>5不成立,因为“++”后缀,之后x的值变为5,执行语句cout<<x--<<end1;输出:5,之后x的值变为4。当读入的数值是6时,因为x++>5成立,所以执行语句cout<<x<<end1;输出7。
转载请注明原文地址:https://kaotiyun.com/show/0XVp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有以下程序:#include<stdio.h>intb=3;intfun(int*k){b=*k+b;return(b);}main(){inta,[10]={1,2,3,4,5,6
设fp为指向某二进制文件的指针,且已读到此文件末尾,则函数feof(fp)的返回值为
结构化程序由顺序、选择、循环三种基本结构组成,以下相关叙述错误的是()。
若有代数式,(其中e仅代表自然对数的底数,不是变量),则以下能够正确表示该代数式的c语言表达式是()。
设已有定义:floatx;,则以下对指针变量p进行定义且赋初值的语句中正确的是( )。
某二叉树有5个度为2的结点,则该二叉树中的叶子结点数是( )。
设数据集合为D={1,2,3,4,5}。下列数据结构B=(D,R)中为非线性结构的是()。
设一棵满二叉树共有15个结点,则在该满二叉树中的叶子结点数为()。
N名学生的成绩已在主函数中放入一个带头节点的链表结构中,h指向链表的头节点。请编写函数fun,其功能是:求出平均分,并由函数值返回。例如,若学生的成绩是:8576698591726487,则平均分应当是:78.625。注意:部分源程序在文
数据库应用系统中的核心问题是()。
随机试题
基督教新教与天主教不同点是()。
世界卫生组织(WHO)提出,在健康促进过程中,应该对健康负责的是
女,45岁,因心慌、胸闷3天入院,心电图显示频发性室性早搏,宜选用哪种抗心律失常药()
设计概算包括( )三级。
监事会有权向股东会提出罢免董事、经理的建议。()
对从事热力、电力、燃气、自来水等公用事业的增值税纳税人收取的一次性费用,凡与货物的销售数量有直接关系的,征收增值税;凡与货物的销售数量无直接关系的,不征收增值税。()
下列属于共同犯罪的是()。
二进制数1001001转换成十进制数是
Idon’tknowwhyhehasbeengiven______.Itwasn’thisaccomplishmentbuthiswife’s.
Haveyouheardaboutspeechtherapy?Aspeechtherapistisaspecialistwhohasbeentrainedto(36)______andtreatthevarious
最新回复
(
0
)