首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序: float fun(int x, int y) { return(x+y);} main() { int a=2, b=5, c=8; printf("% 3.0f\n", fun ((int)fun(a+c
有以下程序: float fun(int x, int y) { return(x+y);} main() { int a=2, b=5, c=8; printf("% 3.0f\n", fun ((int)fun(a+c
admin
2013-02-23
14
问题
有以下程序: float fun(int x, int y) { return(x+y);} main() { int a=2, b=5, c=8; printf("% 3.0f\n", fun ((int)fun(a+c, b) , a-c) ); } 程序运行后的输出结果是______。
选项
A、编译错误
B、9
C、21
D、9
答案
B
解析
函数fun的功能是求两个数之和,其形参数据类型为int型,函数的返回值类型是float型。fun((int)fun(a+c,b),a-c)中有两层函数调用,其中内层调用是fun(a+c,b),因a+c+b=2+8+5=15,而返回类型是float型,所以fun(a+c,b)的值为15.0,将该值强制变换为int型后作为外层函数调用的参数,即fun(15,a-c)=15+a-c=15+2-8=9.0。因printf语句的输出格式为"%3.0f",即小数点后0位小数,故程序的输出为9。
转载请注明原文地址:https://kaotiyun.com/show/rhJp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
下列程序执行输出的结果是【】。#include<stdio.h>f(inta){intb=0;staticc=3;a=c++,b++;return(a);}main()
下面程序的输出结果是#include<stdio.h>main(){inta[]={1,2,3,4,5,6,7,8,9,0},*p;p=a;printf("%d\n",*p+9);}
有如下程序段int*p,a=10,b=1;p=&a;a=*p+b;执行该程序段后,a的值为
当线性表的元素总数基本稳定,且很少进行插入和删除操作,并要求以很快的速度存取线性表中的数据元素时,应采用【】存储结构。
以下函数返回a所指数组中最小的值所在的下标值:fun(int*a,intn){inti,j=0,p;p=j;for(i=j;i<n;i++)If(a[i]<a[p])____
对线性表进行二分法查找,其前提条件是()
按照逻辑结构分类,数据结构可分为线性结构和非线性结构,队列属于【】。
下列不属于软件工程的3个要素的是______。
软件工程研究的内容主要包括:______技术和软件工程管理。
随机试题
在我国,审计监督属()
影响照片密度值的因素不包括
患儿,男,6岁。患结核性脑膜炎,控制炎症首选的治疗是()
健康促进在疾病三级预防中强调
考察国外或国内使用电脑较早的地区,得出其电脑普及率的变化规律,然后根据本地区的实际情况,推断出本地区明年电脑普及率。这是运用市场预测原理中的()。
与音乐一样,人们对于甜味的感觉,也没有国界。不同国家的人,对于甜食的食用有不同的习惯。比方说,西方人习惯以甜点作为进餐的结束,而东方人可能没有这种习惯。但这并不是说,我们对于甜的认知有差异。在全世界,我们看到各式各样的菜系,却很少会在甜点的世界里划分出不同
卢君出牧衢州,有一士投贽①。公阅其文,十篇,皆公所制也。密语曰:“非秀才之文。”对曰:“某②苦心忧课③,非假手也。”公曰:“此某所为文。兼④能暗诵否?”客词穷,吐实曰:“得此文,无名姓,不知是员外撰述。”惶惶欲去。公日:“此虽某所制,亦不示人,秀才但有之。
依法行政是指行政机关应当依据法律规定,在法定权限内,按照法定程序作出证据确凿充分的行为。根据以上定义,下列行为符合依法行政要求的是()
麦克斯威尔·铂金斯是美国现代文学史上最伟大的编辑之一,他曾发掘出司各特·菲茨杰拉德、欧内斯特·海明威、托马斯·沃尔夫等大作家。请问下列那部作品不可能是铂金斯最初编辑出版的?
(1)Almost60%offive-year-oldsinsomeofBritain’spoorestareasdonotreacha"goodlevel"ofbehaviourandunderstanding—do
最新回复
(
0
)