以下程序的运行结果是 ( ) definePI 3.141593 include main( ) { printf("P以下程序的运行结果是 ( ) #definePI 3.141593 #include<stdio.h> main( ) { printf("PI=%fn",PI); }A.3.141593=3.141593B.PI=3.141593C.3.141593=PID.程序有误,无结果

题目
以下程序的运行结果是 ( ) definePI 3.141593 include main( ) { printf("P

以下程序的运行结果是 ( ) #definePI 3.141593 #include<stdio.h> main( ) { printf("PI=%fn",PI); }

A.3.141593=3.141593

B.PI=3.141593

C.3.141593=PI

D.程序有误,无结果


相似考题
更多“以下程序的运行结果是 ( ) #definePI 3.141593 #include<stdio.h> main( ) { printf("P ”相关问题
  • 第1题:

    以下程序运行后的输出结果是( )。 include main() { int x=20; printf("%d", 0

    以下程序运行后的输出结果是( )。

    include<stdio.h>

    main()

    { int x=20;

    printf("%d", 0<x<20);

    printf("%d\n", 0<x && x<20);

    }


    正确答案:10
    10 解析:表达式0x20,首先计算0x,其值为1,再计算120,其值为1,输出1;表达式0x && x20,0x为1,x20为0,再计算1 && 0,其值为0,输出0。所以输出结果为10。

  • 第2题:

    有以下程序:includeincludemain(){char str[][20]={"Hello","Beijing"},*P

    有以下程序: #include <stdio.h> #include <string.h> main() { char str[][20]={"Hello","Beijing"},*P=str[0]; printf("%d\n",strlen(p+20)); } 程序运行后的输出结果是( )。

    A.0

    B.5

    C.7

    D.20


    正确答案:C
    解析:本题考查字符数组和指针的运用。strlen是测试字符串长度的函数,函数的值为字符串的实际长度,不包括'/0'在内。str[][20]={"Hello","Beijing"}定义了一个2行20列的数组,数组的首地址是&str[0][0],p+20是从首地址向后移了20位,指针指向了str[1][0]处,此时求字符串的长度,是从str[1][0]开始的,即“Beijing”的长度,所以输出结果是7。

  • 第3题:

    以下程序运行后的输出结果是。   #include<stdio.h>   main()   {int a=200,b=010;   printf("%d,%dn",a,b);   }


    D 本程序中通过DATA语句对数组B赋值的结果为矩阵DO循环语句的功能是将数组B的第2列的元素的值依次赋值给数组A。因此,A(1)=4、A(2)=5、A(3)=6,所以格式输出数组A后输出的结果为456。

  • 第4题:

    有以下程序:include < stdio. h >main( ){ehar str[ ] [10] = { "China" ," Beijing" } , * p =

    有以下程序: #include < stdio. h > main( ) { ehar str[ ] [10] = { "China" ," Beijing" } , * p = str[o]; printf( "% s \n", p + 10); }程序运行后的输出结果是( )。

    A.China

    B.Beijing

    C.ng

    D.ing


    正确答案:B
    解析:C语言中二维数组是按行存放的,即在内存中先顺序存放第一行的元素,再存放第二行的元素。此题二维数组str[][10]第1行的前5个元素为'C','h','i','n','a',第6个元素为'\0',后4个元素为空字符。紧接着内存单元存放数组第2行的元素,即从str[1][0]到str[1][9]分别为'B','e','i','j','i','n','g',第8个元素为'\0',后两个元素为空字符。执行*p=str[0]后,指针p就指向了二维数组str的首地址,p+10指向从首地址依次向后的第11个存储单元即字符,B,的地址,所以输出Beijing,故答案为B。

  • 第5题:

    以下程序运行后的输出结果是() 。   #include <stdio.h>   #include <stdlib.h>   #include <string.h>   main()   { char *p; int i;    p=(char *)malloc(sizeof(char)*20);    strcpy(p,"welcome");    for(i=6;i>=0;i--) putchar(*(p+i));    printf("n"); free(p);   }


    D 本程序中通过DATA语句对数组B赋值的结果为矩阵DO循环语句的功能是将数组B的第2列的元素的值依次赋值给数组A。因此,A(1)=4、A(2)=5、A(3)=6,所以格式输出数组A后输出的结果为456。