下列程序的运行结果为【】。 include void main(void) {int a=2,b=-1,c=2; if(a下列程序的运行结果为【 】。include<iostream.h>void main(void){int a=2,b=-1,c=2;if(a<b)if(b<0)c=0;else c=c+1;cout<<c<<endl;}

题目
下列程序的运行结果为【】。 include void main(void) {int a=2,b=-1,c=2; if(a

下列程序的运行结果为【 】。

include<iostream.h>

void main(void)

{int a=2,b=-1,c=2;

if(a<b)

if(b<0)c=0;

else c=c+1;

cout<<c<<endl;

}


相似考题
更多“下列程序的运行结果为【】。 include<iostream.h> void main(void) {int a=2,b=-1,c=2; if(a<b) if( ”相关问题
  • 第1题:

    下列程序的运行结果为【】。 include void main(void) {int i=10;switch(i){case 9:i=i

    下列程序的运行结果为【 】。

    include<iostream.h>

    void main(void)

    {int i=10;

    switch(i)

    { case 9:i=i+1;

    case 10:i=i+1;

    case 11:i=i+1;

    default:i=i+1;

    }

    cout<<i<<endl;

    }


    正确答案:13
    13

  • 第2题:

    下列程序的运行结果是______。include class Base { public: void f(int x){cout<<“B

    下列程序的运行结果是______。

    include<iostream.h>

    class Base

    {

    public:

    void f(int x){cout<<“Base:”<<x<<endl;}

    );

    class Derived:public Base

    {

    public:

    void f(char*str){cout<<“Derived:”<<str<<endl;}

    };

    void main(void)

    {

    Base*pd=ne


    正确答案:Base:97。
    Base:97。 解析: 本题主要考查两个知识点,一是基类指针可以指向派生类对象,并可以访问派生类的所有成员。二是在函数重载中进行隐式类型转换。如pd->f(‘a’);系统到底调用哪个重载函数呢?实参既不是派生类中的形参,也不是基类中f函数的形参类型。此时系统根据就近原则和从高优先级到低优先级的规则尝试隐式转换。单字符更接近整数,故调用的是基类的f函数。

  • 第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题:

    下面程序运行时输出结果为【】。 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

  • 第5题:

    下列程序的输出结果是______。includeinclude using namespace std;void

    下列程序的输出结果是______。

    include <iostream.h>

    include <cstring.h>

    using namespace std;

    void fun(const char*s,char &C) {c=s[strlen (s)/2];}

    int main {)

    {

    char str [] ="ABCDE";

    char ch=str[1];

    fun(str,sh);

    cout<<Ch;

    return 0;

    }


    正确答案:C
    C 解析:本题考核数组的定义、使用以及函数的调用。fun函数的作用是将字符串str中间的字符赋值给地址传入的变量ch。所以ch的值将被修改为‘C’。