以下程序的输出结果为() #include "stdio.h"

题目

以下程序的输出结果为() #include "stdio.h" main( ){int a;for(a=0;a<10;a++);printf("%d",a);}

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

第1题:

下面程序的输出结果是( )。 include main() {static char a[]="china"; char*ptr=a; whi

下面程序的输出结果是( )。 include<stdio.h> main() {static char a[]="china"; char*ptr=a; while(*ptr) {printf("%c",*ptr-32); ptr++; } }


正确答案:CHINA
CHINA

第2题:

以下程序的输出结果是( )。 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。

第3题:

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

#include "stdio.h"

main()

{int a=065;

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

}


正确答案:
52

第4题:

以下程序的输出结果是()includeincludemain(){char str[12]={'s','t','r',

以下程序的输出结果是( ) #include<stdio.h> #include<string.h> main() {char str[12]={'s','t','r','i','n','g'}; printf("%d\n",strlen(str)); }

A.6

B.7

C.11

D.12


正确答案:A

第5题:

以下程序的输出结果是() include main( ) { int a,b; for(a=1,b=1,a<=50;a+ +)

以下程序的输出结果是 ( ) # include<stdio.h> main( ) { int a,b; for(a=1,b=1,a<=50;a+ +) { if(b>=10) break; if (b%2==1) { b+=2; continue } b+=2; } printf("%d\n",a); }

A.4

B.5

C.6

D.7


正确答案:C

第6题:

以下程序运行后的输出结果是( )。 include main(){ int a=1, b=7; do { b=b/2; a+=b

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

include<stdio.h>

main()

{ int a=1, b=7;

do {

b=b/2; a+=b;

} while(b>1);

printf("%d\n",A);

}


正确答案:5
5 解析:该程序考查do-while循环。循环共进行两次。第一次循环b=3,a=4;第二次循环b=1,a=5。输出a的值为5。

第7题:

以下程序的输出结果是______。include void swap(int *a, int *b){ int *t;}{ int i=3,j

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

include <stdio.h>

void swap(int *a, int *b)

{ int *t;

}

{ int i=3,j=5,*p=&i,*q=&j;

swap(p,q); printf("%d %d\n",*p,*q);


正确答案:

第8题:

以下程序运行后的输出结果是【】include main ( ) {char a[] ="123456789", *p;int i =0;

以下程序运行后的输出结果是【 】

include <stdio.h>

main ( )

{ char a[] ="123456789", *p;

int i =0;

p=a;

while( * p)

{ if(i%2 ==0) *p='*';

p++;i++;

}

puts(a);

}


正确答案:*2*4*6*8*
*2*4*6*8* 解析:程序中指针p指向数组a,while(*P)语句的循环条件是* p!='\0',在循环体中,当 i=0,2,4,6,8时,i%2=0,执行*p='*',即a[i]='*',继续执行p++;i++;使i为奇数;当i=1, 3,5,7时,i%2=1,继续执行p++;i++;使i为偶数。可见,程序在字符串"123456789",的下标为偶数的位置上赋值'*',代替原字符串中的1,3,5,7,9。所以,程序输出结果为*2*4*6*8*。

第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符合愿意。

更多相关问题