首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
阅读以下C代码,回答下列问题,将解答写入答题纸的对应栏内。 【C代码1】 #include<stdio.h> int main() { int num=5; printf("%d\n", ++
阅读以下C代码,回答下列问题,将解答写入答题纸的对应栏内。 【C代码1】 #include<stdio.h> int main() { int num=5; printf("%d\n", ++
admin
2021-03-24
60
问题
阅读以下C代码,回答下列问题,将解答写入答题纸的对应栏内。
【C代码1】
#include<stdio.h>
int main()
{
int num=5;
printf("%d\n", ++num);
printf("%d\n", num++);
printf("%d\n", num-);
printf("%d\n", num);
return 0;
}
【C代码2】
void func(char ch)
{
while(ch<’f’){
printf("%c:%d\n",ch,ch);
ch+=2;
}
}
【C代码3】
#define CHARS 5
const int ROWS=5;
void test()
{
int row;
char ch;
for(row=0; row<ROWS; row++) {
for(ch=’B’+row; ch<(’B’+CHARS);ch++)
putchar(ch);
printf("\n");
}
}
请给出C代码1运行后的输出结果。
选项
答案
6 6 7 6
解析
C代码1主要考查前置自增(自减)和后置自增(自减)运算的含义。自增(自减)运算是C程序中频繁使用的运算,其含义是将变量的值增加1(减去1)。前置自增时,是将变量的值增加1,增1后变量的值作为表达式的值;后置自增时,是先取变量的值作为表达式的值,然后将变量的值增加1,自减运算同理。本代码段中,num的初始值为5,经过前置自增运算“++num”之后,num的值变为6,该表达式(++num)的值也是num自增后的值,即第一个printf输出6。对于表达式“num++”,是对num进行后置自增,该表达式的值取num自增之前的值(即6,即第二个printf输出6),而num的值变为7。接下来在printf中进行后置自减运算“num-”,此时表达式的运算结果是num自减之前的值(即7,即第三个printf‘输出7),而num的值会改变为6,因此第4个printf输出6。
转载请注明原文地址:https://kaotiyun.com/show/w2jZ777K
本试题收录于:
程序员下午应用技术考试题库软考初级分类
0
程序员下午应用技术考试
软考初级
相关试题推荐
在计算机网络的数据通信中广泛使用的校验方式是(15)。
某工厂信息处理技术员设计了如下统计表:该表设计中包含的问题以及改进方法是______。
Word2007中“复制”命令的功能是将选定的文本或图形()。
银行中最重要、最需要保护的资源是(33)。
以下(1)属于ASP.NET创建的网页程序文件。(1)A.index.aspB.index.htmC.index.aspxrs.close语句的作用是(10)。(10)A.关闭数据库连接B.关闭当前网页
Computer(75)is a complex consisting of two or more connected computing units,it iS used for the purpose of data communication an
A firewall is a(72)system designed to(73)an organization’s network aga-inst threats.
A computer virus is a computer program that is created to make and spread(71)of itself.
If your diskette has been(66), the computer can not store any new information on it.
(70)is not a linear structurE.
随机试题
WhenIwaswalkingdownthestreettheotherday,Ihappenedto【C1】______asmallbrownleatherpurselyingonthesidewalk.I【C2
Thereisameasurablerelationbetweenhowmuchapersonlearnsandhisattitudetowardthesubjecttobelearned.Whenfacedwi
不要求进行无菌检查的剂型是()。
某企业年固定成本为5000万元,产品单价为30元,单位产品可变成本为5元,单位产品销售税金为2元,则盈亏平衡点销售收入为()万元。
()对于企业来说是使用最频繁的媒介。
随园菜的代表菜有:素燕鱼翅、鳆鱼炖鸭、草菇蒸鸡等。()
概念一般都涉及以下要素()。
把资本分为不变资本和可变资本的依据是()。
某次考试100道选择题,每做对一题得1.5分,不做或做错一题扣1分,小李共得100分,那么他答错(包括不做)多少题?()
Likepeople,eachcountryhasuniquecharacteristics.Manycountriesareknownbytheproductstheyproduce.Theseproductsare
最新回复
(
0
)