首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; int main(){ int sum; for(int i = 0; i < 3; i +=
有如下程序: #include using namespace std; int main(){ int sum; for(int i = 0; i < 3; i +=
admin
2021-09-05
22
问题
有如下程序:
#include
using namespace std;
int main(){
int sum;
for(int i = 0; i < 3; i += 1){
sum = i;
for(int j = i; j < 9; j++) sum += j;
}
cout << sum <
return 0;
}
运行时的输出结果是
选项
A、39
B、17
C、110
D、37
答案
D
解析
考查for循环语句,本题中两层for循环,每次i循环,sum都被重新赋值,所以当i=2时,执行完for循环后sum为37。所以答案为D。
转载请注明原文地址:https://kaotiyun.com/show/mOfp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列语句或语句序列中错误的是
有如下程序#includeusingnamespacestd;classAA{charc;public:AA():c(’X’){}AA(A
在C++语言中函数返回值的类型是由()决定的。
在数据库管理技术的发展中,数据独立性最高的是()。
下列叙述中正确的是()。
若有如下程序段:#includeusingnamespacestd;intmain(){char*p="abcdefgh",*r;r=p;cout
以下关键字不能用来声明类的访问权限的是()。
关于运算符重载,下列表述中正确的是()。
下列关于二叉树的叙述中,正确的是()。
下列符号中可以用作C++标识符的是()。
随机试题
发展的实质是()
眼球后麻醉,常用的麻醉药是()。
下列选项中,不是世界贸易组织的组织机构的是( )。
学习策略是为了促进学生学习,与学生的学习内容无关。()
《国家中长期教育改革和发展规划纲要(2010—2020)》中提出的我国今后一个时期教育事业改革发展的工作方针是什么?
共产党员应按照党章履行义务,()。
AdaptationofLivingThingsCertainanimalsandplantsdevelopcharacteristicsthathelpthemcopewiththeirenvironmentbe
Languagelearningbeginswithlistening.Individualchildrenvarygreatlyintheamountoflisteningtheydobeforetheystarts
A、Theyneverjudgepeoplebytheirownnorms.B、Theyarethosewithstrongemotions.C、Theyprobablyhavemorefacialexpression
A、Leaveitvacant.B、Rentittothemanshe’stalkingwith.C、Sublet(转租)ittoMichael.D、Askherlandlordtosubletit.C
最新回复
(
0
)