首页/ 题库 / [单选题]下列程序的运行结果是( )。 #incl的答案

下列程序的运行结果是( )。 #include<iostream.h> int x=5; int fun(int a) { int c; c=x*a; return c; } void main() { int x=3,a=4; x=x+fun(a); cout<<“x="<<x<<end1; }

单选题
2022-02-24 18:06
A、x=15
B、x=17
C、x=23
D、x=25
查看答案

正确答案
C

试题解析
解析:由主函数mian入手,首先x被赋值为3,a被赋值为4。然后调用fun函数,参数为4,所以在fun函数中的a=4。而主程序中的x作用域是由它定义开始到cout输出,在fun函数中无效。而在fun函数定义前的变量x作用域是整个程序,所以fun函数中的x值为5,这样c的值就为20。在主函数中的x+fun(a)中的x为靠近这条语句的x定义,即3,所以最后x的值为20+3=23。

标签:
感兴趣题目
有以下程序 #include<iostream.h> float fun(int x,int y) {return(x+y);} void main( ) {int a=2,b=5,c=8; cout<<fun((int)fun(a+c,b) ,a-c) ;}程序运行后的输出结果是
下列程序的运行结果是 #include<iostream.h> void fun(int*a,int*b) { int*k; k=a;a=b;b=k; } void main() { int a=3,b=6,*x=&a,*y=&b; fun(x,y); cout < < a < < " " < < b; }
下列程序的运行结果是 #inClude<iostream.h> roid fun(int *a,int * b) { int * k; k=a;a=b;b=k;} void main( ) { int a=2004,b=9,* x=&a,* y=&b; fun(x,y); cout < < a < <" " < < b < < end1;}
下列程序的运行结果是( )。 #include< iostream.h> void fun (int *a,int*b) {int*k k=a;a=b;b=k} void main() {int a=2004, b=9,*x=&a,*y=&b; fun(x, y) ; cout<<a<<" "<<b<<endl:}
在下面程序运行后,输出结果为 ______。 #include<iostream.h> void count(int x[],int n,int &y){ int k; y=0; for(k=0:k<n;k++) if(x[k]<0) y++; } void main(){ int b[]={2,1,-8,-3,7,2,4,6,0,-13}; int x; count(b,10,x); cout<<“x”<<x<<end1; }
有如下程序: #include<iostream> using namespace std; class VAC{ public: int f() const{return 3;} int f() {return 5;} }; int main(){ VAC v1; const VAC v2; cout<<v1.f()<<v2.f(); return 0; } 运行时的输出结果是( )。
有以下程序: #include<stdio.h> int f(int x): main {int n=1,m; m=f(f(f(n)));printf("%d ",m); } int f(int x) {return x*2;) 程序运行后的输出结果是( )。
有以下程序: #include <stdio.h> #define N 5 #define M N+1 #define f(x) (x*M) main() { int i1,i2; i1=f(2); i2=f(1+1); printf("%d%d ",i1,i2); } 程序的运行结果是( )。
有以下程序: #include<stdio.h> #define N 5 #define M N+1 #define f(x)(x*M) main() {int i1,i2; i1=f(2); i2=f(1+1); printf("%d%d",i1,i2); } 程序的运行结果是( )。
有以下程序 #include <stdio.h> #define N 5 #define M N+1 #define f(x) (x*M) main() {int i1,i2; i1=f(2); i2=f(1+1); printf("%d%d ",i1,i2); } 程序的运行结果是
运行以下的程序代码,结果是( )。 #include<iostream> using namespace std; intmain() { int x=5; int *q=&x; int &y=x; y++; tout<<(*q)++<<end1; return 0; }
以下程序的输出结果是 #include<iostream.h> void main( ) { int a=21,b=11; cout<<- -a+b;}
相关题目
下列程序的运行结果为 #include<iostream.h> class Location { protected: int X,Y; publiC: void SeX(int myx){X=myx;} void SetY(int myy){Y=myy;} void showxy( ) {cout<<"X=" <<X<<" " <<"Y"=<< Y<< endl;} }; Class Rectangle :public Location{
下列函数的运行结果是( )。 #include<iostream.h> int add(int a,int b); void main() { extern int x,y; cout<<add(x,y)(<endl; ) int x(20),y(5); int add(int a,intB) { int s=a+b; return s; }
有以下程序: #include <stdio.h> int a=2; int f(int *a) { return (*a) ++;} main() { int s=0; { int a=5; s+=f(&a); } s+=f(&a); printf("%d ",s) } 执行后的输出结果是( )。
下列程序的运行结果为 #include<iostream.h> class Location { protected: int X,Y; publiC: void SeX(int myx){X=myx;} void SetY(int myy){Y=myy;} void showxy( ) {cout<<"X=" <<X<<" " <<"Y"=<< Y<< endl;} }; Class Rectangle :public Location{
下列程序的运行结果为( )。 #include<iostream.h> void main() { int a=2; int b=a+1; cou<<afo<<endl; }
有以下程序:#include main(){ int sum=0,x=5; do{ sum+=x; } while(!--x); printf(%d,sum);}程序的运行结果是(  )。
请读程序: # include<stdio.h> f(int b[],int n) { int i,r; r=l; for(i=0;i<=n;i++)r=r*b[i]; return r; } main() { int x a[]={2,3,4,5,6,7,8,9}; x=f(a,3); printf ("%d ",x); } 上面程序的输出结果是 ( )
有以下程序: #include<iostream> using namespace std; int f(int,int); int main() { int i:1,x; x=f(i,i+1); cout<<x<<end1; return 0; } int f(int a,int b) { int c; c = a; if(a>b) c = 1; else if(a==b) c = 0; else c = -2; return c; } 运行后的输出结果是( )。
下列函数的运行结果是( )。 #include<iostream.h> intf( int a, int b) { int c; if(a>b) c=1; elseif(a==b)C=0; elsec=-1; return(c);} void main() {int i=2,j=3; int p=f(i,j); cout<<p;}
下面程序的运行结果是( )。 #include<iostream.h> int x=5; int fun(int a) { int c; C=X*a; retum c; } void main() { int x=3,a=4; x=x+fun(a); cout<<"x"”<<X<<endl; }
下面程序的运行结果是( )。 #include<iostream.h> int x=5; int fan(int a) { int c; c=x*a; return c; } void main() { int x=3,a=4; x=x+fun(a); eout<<"x="<<x<<end1; }
下列程序的运行结果是( )。 #include<iostream.h> int x=5; int fun(int a) { int c; c=x*a; return c; } void main() { int x=3,a=4; x=x+fun(a); cout<<“x="<<x<<end1; }
下列程序的运行结果是( )。 #include<iostream.h> int x=5; int fun(int A) { int C; C=X*a; return C; } void main() { int x=3,a=4; x=x+fun(a); cout<<"x="<<x<<endl; }
下列函数的运行结果是 #include<iostream.h> int f(int a,int b) { int c; if(a>b)c=1; else if(a==b)C=0; else c=-1; return(c);} void main() { int i=2,j=3; int p=f(i,j); cout<<p;}
下列函数的运行结果是 #include<iostream.h> int f(int a,int B) {int c; if(a>b) c=1 else if(a=b) c=0; else c=-1; return(c) ;} void main( ) { int i=2,j=3; int p=f(i,j); cout
有以下程序 #include<iostream.h> floatfun(int x,int y) {return(x+y);} void main() {int a=2,b=5,c=8; tout<<fun((int)fun(a+c,b),a-C);} 程序运行后的输出结果是
有以下程序 float fun(int x,int y) { return(x+y);} main() { int a=2,b=5,c=8; printf("%3.0f ",fun((int)fun(a+c,b),a-c));} 程序运行后的输出结果是
有以下程序: float fun(int x, int y) { return(x+y);} main() { int a=2, b=5, c=8; printf("% 3.0f ", fun ((int)fun(a+c, b) , a-c) ); } 程序运行后的输出结果是______。
有以下程序 float fun(int x,int y) { return(x+y); } main() { int a=2,b=5,c=8; printf("%3.0f ",fun((int)fun(a+c,B) ,a-C) ); } 程序运行后的输出结果是( )
有以下程序: float fun(int x,int y) {return(x+y);} main() { int a=2,b=5,C=8; printf("%3.0f ",fun((int)fun(a+c,b),a-c)); } 程序运行后的输出结果是( )。
广告位招租WX:84302438

免费的网站请分享给朋友吧