下列程序的运行结果为()。include void main(){int a=2;int b=a+1;cou下列程序的运行结果为( )。 #include<iostream.h> void main() { int a=2; int b=a+1; cou<<afo<<endl; }A.0.66667B.0C.0.7D.0.66666666

题目
参考答案和解析
正确答案:B
更多“下列程序的运行结果为()。#include<iostream.h> void main(){int a=2;int b=a+1;cou<<afo<<endl;} ”相关问题
  • 第1题:

    下面程序运行时输出结果为【】。 include include class Rect { public: Rec

    下面程序运行时输出结果为【 】。

    include<iostream.h>

    include<malloc.h>

    class Rect

    {

    public:

    Rect(int1,int w)(length=1;width=w;)

    void Print(){cout<<"Area:"<<length *width<<endl;)

    void *operator new(size-t size){return malloc(size);}

    void operator delete(void *p){free(p)

    private:

    int length,width;

    };

    void main()

    {

    Rect*p;

    p=new Rect(5,4);

    p->Print();

    delete p;

    }


    正确答案:Area:20
    Area:20

  • 第2题:

    下列程序的运行结果为()。includevoid main(){int a=2;int b=a+1;cout<

    下列程序的运行结果为( )。 #include<iostream.h> void main() { int a=2; int b=a+1; cout<<a/b<<endl; }

    A.0.66667

    B.0

    C.0.7

    D.0.66666666…


    正确答案:B

  • 第3题:

    下面程序的结果为______。include void main() { int 3=1,b=2; bool c=1; if(a>b)||c

    下面程序的结果为______。

    include<iostream.h>

    void main()

    {

    int 3=1,b=2;

    bool c=1;

    if(a>b)||c)cout<<“true”<<endl;

    else

    cout<<“false”<<endl;

    }


    正确答案:true。
    true。 解析: 本题考查的是对于逻辑运算符号的理解,”||”运算符的任何一边取值为真,则整个运算结果为真。

  • 第4题:

    下列程序段的输出结果是includevoid fun(int * x,int * y){cout<<* X<<* y; *X=3;

    下列程序段的输出结果是 #include<iostream.h> void fun(int * x,int * y) { cout << * X << * y; *X=3; *y=4; } void main() { int x=1,y=2; fun(&y,&x); cout << X << y<<endl; {

    A.2143

    B.1212

    C.1234

    D.2112


    正确答案:A
    解析:在fun函数中,x接收的是main函数中y的地址,所以*x值为2,同样,*y值为1,所以第1次输出的是21,第2次改变*x的值等同于改变y的值,改变*y的值也即改变x的值,所以第2次输出的是43。注意:C++语言中函数的传参方式中关于指针的应用。

  • 第5题:

    下列程序段的输出结果是includevoid fun(int*x,int*y){cout<<*x<<*y;*X=3;*y=4;}vo

    下列程序段的输出结果是 #include<iostream.h> void fun(int*x,int*y) {cout<<*x<<*y; *X=3; *y=4; } void main() {int x=1,y=2; fun(&y,&x); cout<<X<<y<<endl; }

    A.2143

    B.1212

    C.1234

    D.2112


    正确答案:A