单选题有以下程序:#includedoublef(doublex);main(){ doublea=0; inti; for(i=0;i30;i+=10)a+=f((double)i); printf(%5.0f,a);}doublef(doublex){ returnx*x+1;}程序运行后的输出结果是(  )。A 503B 401C 500D 1404

单选题
有以下程序: #include  double f(double x); main() {  double a=0;  int i;  for(i=0;i<30;i+=10) a+=f((double)i);  printf(%5.0f,a); } double f(double x) {  return x*x+1; } 程序运行后的输出结果是(  )。
A

503

B

401

C

500

D

1404


参考解析

解析:
函数f的功能是计算传入的实参x的平方加一,然后将结果返回。i初始值为0,根据x*x+1,即第一次返回值为1,然后执行i=i+10,第二次i的值为10,即返回值为101+1=102,第三次i的值为20,即返回值为401+102=503。注意输出格式,5位浮点型输出。答案选择A选项。

相关考题:

以下程序的输出结果是______。 include int add(int x, int y) { return x+y; } doub 以下程序的输出结果是______。include<iostream.h>int add(int x, int y){return x+y;}double add(double x, double y){return x+y;}void main(){int a=3, b=3;double c=6.5, d=1.5;cout<<add(a, b)<<","<<add(c, d)<<end1;}

下面程序的输出结果是【】。include include class point{double x; double y; 下面程序的输出结果是【 】。include <iostream.h>include <math.h>class point{double x;double y;public:point(double a, double b){x=a;y=b;}friend double distance(point a, point b) ;};double distance(point a, point b){return sqrt ((a. x-b.x) * (a. x-b.x)+ (a. y-b. y) * (a. y-b. y) );}void main(){point p1(1,2);point p2(5,2);cout<<distance(p1,p2)<<end1;}

阅读下列程序说明和C++代码,将应填入(n)处。【说明】①在类体中添加函数move(double ax,double ay)的定义,使得点的坐标x和y分别移动 ax和ay个单位。②在类定义外完成重载的两个构造函数CPosition()和CPosition(double dx,double dy),其中前者为不带参数的构造函数,使CPosition对象的默认值为x=0,y=0,后者为带参数的构造函数,把数据成员x和y分别初始化为参数dx和dy的值。③完成函数double distance(double bx,double by)的定义,该函数返回*this和点(bx, by)的距离。注意:除在指定的位置添加语句外,请不要改动程序中的其他语句。源程序文件test5.cpp清单如下:include<iostream.h>include<math.h>class CPosition{public:CPosition();CPosition(double dx,double dy);double getx();double gety();(1)double distance(double bx,double by);private:double x;double y;};(2){x=0;y=0;}CPosition::CPosition(doub,e dx,doub,e dy){x=dx; y=dy;}double CPosition::getx(){return x;}double CPosition::gety(){return y;}double CPosition::distance(double bx,double by){(3)}vold main(){double a,b;cout<<"|nput x,y position of a point:";cin >> a >> b;CPosition psA(a,b);cout<<"Input x,y position of another point:";cin >>a >> b;cout <<"The distance is" <<psA.distance(a,b) <<end1;}

有以下程序 include typedef struct { int num;double s; }REC; void funl(REC *x) { x 有以下程序 include<stdio.h> typedef struct { int num;double s; }REC; void funl(REC *x) { x->num=23;x->s=88.5; } void main() { REC a={16,90.0}; fun1(A); printf("%d\n",a.num); } 程序运行后的输出结果是( )。

请编写函数fun(),它的功能是计算下列级数和,和值由函数值返回。S=1+x+x2/2!3/3!+…/xn/n!例如,当n=10,x=0.3时,函数值为1349859。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun 的花括号中填入所编写的若干语句。试题程序:include<conio.h>include<stdio.h>include<math.h>double fun(double x, int n){}main (){clrscr ();printf ("%f ",fun(0,3,10));}

分析以下程序执行结果【】。 include int f (int x, int y){return x,y; } double f (d 分析以下程序执行结果【 】。include<iostream.h>int f (int x, int y){return x,y;}double f (double x, double y) {return x,y;}void main() {int a=4, b=6;double c=2.6, d=7.4;cout<<f (a, b) <<","<<f (c, d) <<end1;}

有以下程序,请在 处填写正确语句。使程序可正常编译运行。include;mairl();{double x,y,(*p)():scanf(“%If%If”,x,y);P=avg;printf(“%f\n”,(*p)(x,y));}double avg(double a,doublc b){return((a十b/2):

下列程序的运行结果为【】。 include include {int a; char b[10]; double c;}; 下列程序的运行结果为【 】。include<stdio.h>include<string.h>{ int a; char b[10]; double c; };void f (struct A *t);main(){ struct A a={1001,"ZhangDa",1098.0};f(a) ; printf("%d,%s,%6.lf\n",a.a,a.b,a.C);}void f(struct A*t){ strcpy(t->b, "ChangRong");}

有以下程序 include main() { struct STU{char name[9];char sex;double 有以下程序 #include <stdio.h> main() { struct STU{char name[9];char sex;double score[2];}; sturt STU a={"Zhao" ,'m',85.0,90.0},b={"Qian" ,'f,95:0,92.0}; b=a; printf("%s,%c,%2.0f,%2.0f\n",b.name,b.sex,b.score[0],b.score[1]); } 程序的运行结果是______。A.Qian,f,95,92B.Qian,85,90C.Zhao,f,95,92D.Zhao,m,85,90

写出下列程序的运行结果【】。 include void func(double x, int part1, double 写出下列程序的运行结果【 】。include<iostream. h>void func(double x, int part1, double part2){part1=int(x)+500:part2=(x+500-part1)*100;}void main( ){int n;double x, f;x=1001. 0103;func (x, n, f):cout<<"Part 1="<<n<<" , part2="<<f<<end1}

有以下程序:includeincludeusing namespace std; class point{private:double 有以下程序: #include<iostream> #include<math> using namespace std; class point { private: double x; double y; public: point(double a,double B) { x=a; y=b; } friend double distance (point a,point B) ;A.1B.5C.4D.6

有以下程序:include include using namespace std;class point{private:doubl 有以下程序:#include <iostream>#include <math>using namespace std;class point{private: double x; double y;public: point(double a, double b { x=a; y=b; friend double distance (point a, point b ; };double distance(point a, point b return sqrt((a. x-b. x )*(a. x -b. x )+ (a. x -b. x)*(a. x-b. x));}int main (){ point p1 (1,2); point p2(5,2); cout<<distance (p1, p2)<<end1; return 0;} 程序运行后的输出结果是A.1B.5C.4D.6

以下程序的输出结果是【】。 include int add(int x,int y) { retum X+y; } dOuble ad 以下程序的输出结果是【 】。include<iostream.h>int add(int x,int y){retum X+y;}dOuble add(dOUble x,double y){return x+y;}void main(){int a=4,b=6;double c=2.6,d=7.4;cout<<add(a,b)<<",”<<add(C,d)<<endl;}

有以下程序: #includestdio.h double f(double x); main( ) {double a=0; int i; for(i=0;i30;i+=10)a+=f((double)i); printf("%5.of\n",a); } double f(double x) { return x*x+1; } 程序运行后的输出结果是( )。A.503B.401C.500D.1404

有以下程序:include include using namespace std;class point{private: doub 有以下程序: #include <iostream> #include <math> using namespace std; class point { private: double x; double y; public: point(double a,double b) { x=a; y=b; } friend double distance(point a,point b) ; }; double distance(point a,point b) { return sqrt ((a.x-b.x)* (a.x-b.x)+(a.y-b.y)*(a.y-b.y)); } int main ( ) { point pl(1,2); point p2 (5, 2); cout<<distance (pl,p2) <<end1; return 0; } 程序运行后的输出结果是( )。A.1B.5C.4D.6

有以下程序; int f1(double A) { return a*a; } int f2(double x,double y) { double a, b; a=n(x); b=f1(y); return a+b; } main() { double w; w=f2(1.1,2.0); ┇ } 变量w中的值是( )A.5.21B.5C.5D.0

有以下程序#includestdio.hdouble f(double x);main(){ double a=0;int i;for(i=0;i30;i+=10) a+=f((double)i);printf("%5.0f\n",a);}double f(double x){return x*x*i;}程序运行后的输出结果是A.503B.401C.500D.1404

有下列程序:includeusing namespace std;int main(){void function(double val);doub 有下列程序: #include<iostream> using namespace std; int main() { void function(double val); double val; function(val); cout<<val; return 0; } void fimction(double val) { vA.编译出错,无法运行B.输出3C.输出:3.0D.输出一个不确定的数

有以下程序:include include void main(){double d= 123.456789;cout 有以下程序:#include <iostream.h>#include void main(){ double d= 123.456789; cout<<setprecision(3)<<d<<","; cout<<setprecision(4)<<d<<","; cout<<setprecision(5 )<<d<<end1;}程序执行后的输出结果是( )。A.123,123.4,123.45B.123,123.5,123.46C.123,123,123.4D.123.456789,123.456789,123.456789

有如下程序:includeusing namespace std;int main(){void function(double val);doub 有如下程序: #include<iostream> using namespace std; int main() { void function(double val); double val; function(val); cout<<val; return 0; } void function(double val) { val= 3; } 编译运行这个程序将出现的情况是( )。A.编译出错,无法运行B.输出:3C.输出:3.0D.输出一个不确定的数

有以下程序:includemain(){int a;char c=10; float f=100.0;double x; a=f/=c*=(x=6.5 有以下程序: #include <stdio.h> main() { int a; char c=10; float f=100.0; double x; a=f/=c*=(x=6.5); printf("%d%d%3.1f%3.1f\n",a,c,f,x); } 程序运行后的输出结果是( )。A.1 65 1 6.5B.1 65 1.5 6.5C.1 65 1.0 6.5D.2 65 1.5 6.5

下列程序的输出结果是______。 include main() { double d=3.2;int x,y; x=1.2;y=(x+3. 下列程序的输出结果是______。 #include<stdio.h> main() { double d=3.2;int x,y; x=1.2;y=(x+3.8)/5.0; printf("%d\n",d*y); }A.3B.3.2C.0D.3.07

下列程序不能通过编译,应该在划线部分填写的语句是______。 include include 下列程序不能通过编译,应该在划线部分填写的语句是______。include<iostream.h>include<stdlib.h>double Func(int a,int b,char ch){double x;switch(ch){case'+':x=double(a)+b;break;case '-':x=double(a)-b;break;case '*':x=double(a)*b;break;case'/':if(B)x=double(a)/b;elseexit(1);break;default:exit(1);}______}void main( ){cout<<Func(32,6,'-')<<",";cout<<Func(32,6, '*')<<",";cout<<Func(32,6,'/')<<endl;}

试题24有以下程序#include stdio.hdouble f(double x);main(){ double a=0; int i;for(i=0;i30;i+=10) a+=f((double)i);printf(“%5.0f\n”, a);}double f(double x){ return x*x+1;}程序运行后的输出结果是()A.503B.401C.500D.1404

试题31以下程序的主函数中调用了在其前面定义的fun函数#include stdio.h………main(){ double a[15], k;k=fun(a);…}则以下选项中错误的fun函数首部是()A.double fun(double a[15])B.double fun(double *a)C.double fun(double a[])D.double fun(double a)

(12)有以下程序,请在 【12】 处填写正确语句,使程序可正常编译运行。#include stdio.h【12】 ;main(){ double x,y,(*p)();scanf("%lf%lf",x,y);p=avg;printf("%f\n",(*p)(x,y));}double avg(double a,double b){ return((a+b)/2);}

单选题有以下程序:#include #include main(){ int a = 1,b=4,c = 2; double x = 10.5,y = 4.0,z; z = (a + b)/c + sqrt(y)*1.2/c+x; printf(%f,z);}程序运行后的输出结果是(  )。A13.700000B14.000000C15.400000D14.900000

单选题有以下程序:#includefloat fun(double a){ double x; x=a-(int)a; return x;}main(){ double a=3.1415; printf(%f,fun(a));}程序的运行结果是(  )。A3.000000B3.141500C0.141500D0.000000