首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错误,请改正程序中的错误,使得程序输出: number1=4.8 number2=93.6 number3=0.9 PRODUCT=404.352 注意:错误的语句在//******e
使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错误,请改正程序中的错误,使得程序输出: number1=4.8 number2=93.6 number3=0.9 PRODUCT=404.352 注意:错误的语句在//******e
admin
2019-05-14
30
问题
使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错误,请改正程序中的错误,使得程序输出:
number1=4.8 number2=93.6 number3=0.9
PRODUCT=404.352
注意:错误的语句在//******error******的下面。修改该语句即可。其他的语句不能修改。
#include<iostream>
using namespace std;
int main()
{
double number1=4.8,number2=93.6,number3=0.9;
//********error********
product=number1*number2*number3;
//********error********
cout<<"number1="<<number1<’\t’<<"number2="<<number2<<’\t。’;
//********error********
cout<<"number3="<<number3<<’\t’;
cout<<"PRODUCT="<<product(<endl;
return0;
}
选项
答案
(1)doubleproduct=number1*number2* number3; (2)cout<<"number1="<<number1<<’\t’<<"number2="<<number2<<’\t’; (3)cout<<"number3="<<number3<<’\t’<<endl;
解析
(1)C++要求变量在定义后才能使用,显然product变量没有定义,number1、number2和number3均为double型变量,product是这三个变量的乘积,因此product的数据类型是double型,因此第1个标识下应改为doubleproduct=number1*number2*number3。
(2)cout流中的数据是用流插入运算符“<<”顺序加入的,第2个标识下是输出number1、number2和number3的值,各个数据之间用“<<”顺序加入,不能用“<”,第2个标识下应改为cout<<"number1="<<number1<<’\t’<<"number2="<<number2<<’\t’。
(3)由于输出“PRODUCT=404.352”在“number1=4.8number2=93.6number3=0.9”下一行,因此输出“number3=0.9”后应换行,故第3个标识下应改为“cout<<"number3="<<number3<<’\t’<<endl;”。
转载请注明原文地址:https://kaotiyun.com/show/ob8p777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
在下面的4个关键字中用来说明虚函数的是()。
有如下程序:#include<iostream>usingnamespacestd;classTestClass{public;~TestClass(){cout<<"BASE:;}};cla
分析下面程序,该程序的运行结果是()。#include<iostream.h>classTestClass{public;staticintm;TestClass(){m++;
在C++语言中函数返回值的类型是由()决定的
阅读以下程序:#include<iostream.h>voi6main(){staticinta[][2]={5,3,1,2};inti,j,s1=0;for(i=0;i<2;i++)for(
有如下程序:#include<iostream>usingnamespacestd;classCon{charID;public:Con():ID(’A’){cout<<1;}Con(
有如下程序:#include<iostream>voidfun(int&x,inty){intt=x;x=y;y=t;}intmain(){inta[2]={23,42};fun(a[1],a
随机试题
在立式铣床上铣削平行面,若工件上没有台阶,先把工件夹紧,再用()固定在铣床工作台上进行找正。
毫无疑问,我们正在做的事情有助于社会发展。
台湾与大陆和平统一后,台湾特别行政区可以享有比香港、澳门特别行政区更高度的自治权利,主要体现在【】
结核球的直径大小为
[1997年第153题]当居住区的规划结构确定为二级结构时。下列哪条较为合理:
明洞主要分为两大类,即()。
小组是一个有生命的发展周期,有着自身发展的规律和过程。()
在完全竞争的条件下,市场均衡意味着资源的最佳配置,而打破市场均衡的可能原因有()。
甲为某工商机关领导,乙为某公安机关领导,乙的朋友丙欲开设一个公司,丙将所有材料报上后不见工商局通知,经询问说还没有来得及审阅。半年之后,丙怕工商局一拖再拖,遂求乙给甲打电话说说,并送给乙8万元,乙拿出其中5万元送给了甲,甲由于没有直接分管此事,又嫌送钱太少
"TheDigitalDivide"TheChallengeofTechnologyandEquityInformationtechnologyisinfluencingthewaymanyofuslive
最新回复
(
0
)