niusouti.com

有如下程序段: includedefine Max(a,b) a>b?a:bmain(){int a=5,b=6,c=4,d;d=c+Max(a,有如下程序段: #include<stdio.h> #define Max(a,b) a>b?a:b main() { int a=5,b=6,c=4,d; d=c+Max(a,b); printf("%d",d); } 其输出结果为______。A.10B.5C.6D.编译错误

题目
有如下程序段: includedefine Max(a,b) a>b?a:bmain(){int a=5,b=6,c=4,d;d=c+Max(a,

有如下程序段: #include<stdio.h> #define Max(a,b) a>b?a:b main() { int a=5,b=6,c=4,d; d=c+Max(a,b); printf("%d",d); } 其输出结果为______。

A.10

B.5

C.6

D.编译错误


相似考题
参考答案和解析
正确答案:B
解析:在C语言中,宏定义是直接替换的,所以在c+a>b?a:b这个条件表达式中,c+a>b为真,所以用a的值作为整个表达式的值,而a的值为5,所以整个表达式的值为5。
更多“有如下程序段: #include<stdio.h>#define Max(a,b) a>b?a:bmain(){int a=5,b=6,c=4,d;d=c+Max(a, ”相关问题
  • 第1题:

    在C程序中如果要使用数学函数,如sin(x),log(x)等,需要在程序中加入的语句是

    A.#include <math.h>

    B.#include <stdio.h>

    C.#define <math.h>

    D.#define <stdio.h>


    C

  • 第2题:

    16、在C程序中如果要使用数学函数,如sin(x),log(x)等,需要在程序中加入的语句是

    A.#include <math.h>

    B.#include <stdio.h>

    C.#define <math.h>

    D.#define <stdio.h>


    #include

  • 第3题:

    在C程序中如果要使用数学函数,如sin(x),log(x)等,需要在程序中加入的语句是()

    A.#include <stdio.h>

    B.#define <stdio.h>

    C.#include <math.h>

    D.#define <math.h>


    #include

  • 第4题:

    在C程序中如果要使用数学函数,如sqrt(x),pow(x,y)等,需要在程序中加入的语句是______

    A.#define <math.h>

    B.#define <stdio.h>

    C.#include <stdio.h>

    D.#include <math.h>


    C

  • 第5题:

    2、在C程序中如果要使用数学函数,如sin(x),log(x)等,需要在程序中加入的语句是

    A.#include <math.h>

    B.#include <stdio.h>

    C.#define <math.h>

    D.#define <stdio.h>


    A