以下程序的输出结果是_______。#include<stdio.h>main(){printf("%d\n",NULL);}A.不确定的(因变量

题目
以下程序的输出结果是_______。includemain(){printf("%d\n",NULL);}A.不确定的(因变量

以下程序的输出结果是_______。 #include<stdio.h> main() { printf("%d\n",NULL); }

A.不确定的(因变量无定义)

B.0

C.-1

D.1

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

第1题:

有以下程序 include main() { int n,*p=NULL; *p=&n; printf("

有以下程序 #include <stdio.h> main() { int n,*p=NULL; *p=&n; printf("Input n:");scanf("%d",&p);printf("output n:");printf("%d\n",p); } 该程序试图通过指针p为变量n读入数据并输出,但程序有多处错误,以下语句正确的是

A.int n,*p=NULL;

B.*p=&n;

C.scanf("%d",&p)

D.printf("%d\n",p);


正确答案:A
解析:指针变量在定义时需要加星号,而在赋值时则不用,故选项B)错误。本题中,scanf()函数和printf()函数都是要对指针变量p指向的地址处的数据进行访问,不是变量本身。选项C)中多了取地址运算符,选项D)中少了指针运算符。

第2题:

以下四个程序中,完全正确的是()。A.include main( ); { /* programmlng* / printf( "p

以下四个程序中,完全正确的是( )。

A.#include <stdio.h> main( ); { /* programmlng* / printf( "programming! \n" ); }

B.#include <stdio.h> main( ) { /*/programming printf("programming! \n"); }

C.#include <stdio.h> main( ) { /*programming* / printf( "programming! \n" ); }

D.include <stdio.h> main ( ) { /*/* programming*/*/ printf( "programming! \n" ); }


正确答案:C
解析:选项A)main();后面不应该有分号;选项B)中的注释语句不正确;选项D)的include前缺少#。

第3题:

以下四个程序中,完全正确的是( )。A.includeB.include main(); main() {/*pr

以下四个程序中,完全正确的是( )。

A.#include<stdio.h>

B.#include<stdio.h> main(); main() {/*programming*/ {/*/programming/*/ printf("programming!\n");} printf("programming!\n");}

C.#include<stdio.h>

D.include<stdio.h> main() main() {/*/*programming*/*/ {/*programming*/ printf("programming!\n");} printf("programming!\n");}


正确答案:B
解析:选项A中的main()后面不能直接用分号。选项C中的注释符使用不正确,编译器会把从第一个“/*到第一个*/”之间的当作注释,最后一个“*/”会被作为程序代码去编译。选项D中的include前要加上#表示是预定义语句。

第4题:

执行以下程序的输出结果是【 】。include main()[ inti, n[4]={1};for(i= 1 ;i<=3 ;i++){

执行以下程序的输出结果是【 】。

include <stdio.h>

main()

[ int i, n[4]={1};

for(i= 1 ;i<=3 ;i++)

{ n[i]=n[i-1]*2+1; printf("%d",n[i]); }


正确答案:3 715
3 715 解析:本题考查的知识点是:for循环。本题主函数中的for循环从1递增到3,所以将循环3次。循环体中,n[i]=n[i-1]*2+1;语句使数组n从第2个元素开始,后一个元素等于前一个元素的2倍加1;print("%d",n[i]);输出刚计算出的数组n的元素。故结果应该是1*2+1=3、3*2+1:7、7*2+1=15。即输出结果为3 715。

第5题:

以下程序的输出结果是( )。 includefun(){ int a=0;a+=3;printf("%d",A); } main() {int

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

include<stdio.h>

fun()

{ int a=0;

a+=3;

printf("%d",A);

}

main()

{ int cc;

for(cc=1;cc<=4;cc++)

fun();

printf("\n");

}


正确答案:3 3 3 3
3 3 3 3 解析:本题考查for循环,for(cc=1;cc=4;cc++)表示循环4次,a+=3表示每次a的值增加3,但是子函数中没有将变量a定义为static类型,所以每次调用完子函数之后,变量a所做的改变都不能保存,这样在下一次调用子函数时,a的初值仍是0,所以不管调用多少次,子函数输出始终是3。

第6题:

以下程序的输出结果是 【7】 。

#include "stdio.h"

main()

{int a=065;

printf( "%d\n",--a);

}


正确答案:
52

第7题:

以下程序的输出结果是( )。 include void fun(int x) {if(x/2>0)fun(x/2); printf("%d",

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

include<stdio.h>

void fun(int x)

{ if(x/2>0)fun(x/2);

printf("%d",x);

}

main()

{fun(3);printf("\n");

}


正确答案:13
13 解析:函数fun是一个递归函数。执行fun(3);,x=3,x/2=1>0,又调用f(1),此时,x=1,x/2=0,不满足继续递归调用的条件,输出1,返回到fun(3)中,输出3。所以本题的输出结果为13。

第8题:

以下程序的输出结果是______。 main() {printf("%d\n",NULL); }

A.0

B.-1

C.1

D.不确定的值(因变量无定义)


正确答案:A
解析:NULL表示空,常在定义指针变量时将其值赋为NULL,表示不指向任何地址。NULL在C语言的头文件中宏定义为0。

第9题:

有以下程序 include main( ) { printf("%d\n",NULL); } 程序运行后的输出结果是

有以下程序

#include <stdio.h>

main( )

{ printf("%d\n",NULL); }

程序运行后的输出结果是

A.0

B.1

C.-1

D.NULL没定义,出错


正确答案:A
解析:因为在头文件stdio.h中,已对NULL作了宏定义,其值为0。

第10题:

有以下程序:include main(){ printf("%d\n",NULL);}程序运行后的输出结果是()。A.0B.1C

有以下程序: #include<stdio.h> main() { printf("%d\n",NULL);} 程序运行后的输出结果是( )。

A.0

B.1

C.-1

D.NULL没定义,出错


正确答案:A
解析:在C语言中NULL的ASCII码值为0,而输出函数要求以整形格式输出,故最后的输出数为0。所以,4个选项中选项A符合愿意。

更多相关问题