计算机二级

下面程序错误的语句是 #include“iostream.h” ① void main( ) ② { ③ int A=0; ④ int &B; ⑤ B=A; ⑥ cout<<B; ⑦ cout<<A; ⑧ }A.②B.③C.④D.⑥

题目

下面程序错误的语句是 #include“iostream.h” ① void main( ) ② { ③ int A=0; ④ int &B; ⑤ B=A; ⑥ cout<<B; ⑦ cout<<A; ⑧ }

A.②

B.③

C.④

D.⑥

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

下面程序错误的语句是①include ②void main()③{④int * p=new int[1]⑤p=9⑥cout<<* p<

下面程序错误的语句是

①#include<iostream.h>

②void main()

③{

④ int * p=new int[1]

⑤ p=9

⑥ cout<<* p<<end1;

⑦ delete []p;

⑧}

A.④

B.⑤

C.⑥

D.⑦


正确答案:B
解析:本题考查的是指针的使用,p是指向int型的指针,若想给它指向的元素赋值,应使用*符号,直接赋值相当于改变了原来p存储的地址。

第2题:

下面程序错误的语句是 #include"iostream.h" ① void main() ② { ③ int A=0; ④ int & B; ⑤ B=A ⑥ cout<<B; ⑦ cout<<A; ⑧ }

A.②

B.③

C.④

D.⑥


正确答案:C
解析:引用必须在第一时间进行赋值,int&B没有在第一时间赋值故错误。注意:引用的方式,引用和指针应用的比较。

第3题:

下面程序错误的语句是 #include" iostream.h" ① void main( ) ② { ③ int A=0; ④ int & B; ⑤ B=A; ⑥ cout < < B; ⑦ cout < < A; ⑧ }

A.②

B.③

C.④

D.⑥


正确答案:C
解析:引用必须在第一时间进行赋值,int&B没有在第一时间赋值故错误。注意:引用的方式,引用和指针应用的比较。

第4题:

下面程序错误的语句是 #include"iostream.h" ① void main() ② { ③ int A=0; ④ int&B; ⑤ B=A; ⑥ cout<<B; ⑦ cout<<A; ⑧ }

A.②

B.③

C.④

D.⑥


正确答案:C

第5题:

下面程序的运行结果是 include void fun(int * a,int * b) { int x= * a; * a= *

下面程序的运行结果是

#include<iostream.h>

void fun(int * a,int * b)

{

int x= * a;

* a= * b; * b=X;

cout < < * a < < * b < <" ";

}

void main( )

{

int x=1,y=2;

fun(&x,&y) ;

cout < < X < < y < < endl;

}

A.12 12

B.12 21

C.21 12

D.21 21


正确答案:D
解析:本题考查的是指针和引用,函数 fun完成把x和y互换的操作。

第6题:

下面程序错误的语句是 ① include ② void main( ) ③ { ④ int * p=new int[1] ; ⑤ p

下面程序错误的语句是

① #include<iostream.h>

② void main( )

③ {

④ int * p=new int[1] ;

⑤ p=9;

⑥ cout < < * p < <endl;

⑦ delete[ ] p;

⑧ }

A.④

B.⑤

C.⑥

D.⑦


正确答案:B
解析:本题考查的是指针的使用,p是指向int型的指针,若想给它指向的元素赋值,应使用。符号,直接赋值相当于改变了原来p存储的地址。

第7题:

下列程序的运行结果是()。include< iostream.h>void fun (int *a,int*b){int*kk=a;a=b;b=k}void

下列程序的运行结果是( )。 #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:}

A.20049

B.92004

C.0

D.编译时出错


正确答案:A

第8题:

下面程序的运行结果是includevoid fun(int * a,int * b){ int x= * a; * a = * b;*

下面程序的运行结果是 #include<iostream.h> void fun(int * a,int * b) { int x= * a; * a = * b; * b=x; cout <<*a<< *b<<""; } void main( 0 { int x =1,y =2; fun(&x,&y); cout<< x << y <<end1; }

A.12 12

B.12 21

C.21 12

D.21 21


正确答案:D
解析:本题考查的是指针和引用,函数 fun完成把x和y互换的操作。

第9题:

下面程序错误的语句是①include < iostream.h>②void main( 0③{④int * p = new int[1] ;⑤p =9;⑥co

下面程序错误的语句是 ①#include < iostream.h> ②void main( 0 ③{ ④ int * p = new int[1] ; ⑤ p =9; ⑥ cout <<*p <<end1; ⑦ delete [ ] p; ⑧ }

A.④

B.⑤

C.⑥

D.⑦


正确答案:B
解析:本题考查的是指针的使用,p是指向int型的指针,若想给它指向的元素赋值,应使用 *符号,直接赋值相当于改变了原来p存储的地址。