定义语句出错,case是关键字,不能用作用户自定义标识符
定义语句出错,printF不能用作用户自定义标识符
定义语句无错,scanf不能作为输入函数使用
定义语句无错,printf不能输出case的值
第1题:
若从键盘输入34,则以下程序输出的结果是______。
include<stdio.h>
main()
{ int a;
scanf("%d",&a);
if(a>30)printf("%d",a);
if(a>20)printf("%d",a);
if(a>10)printf("%d",a);
}
第2题:
以下程序段的运行结果是( )。 include<stdio.h> main() {int x=2,y=1: switch(x) {case 1: switch(y) {case 0:printf("x=2,y=1\n");break; case 1:printf("y=1\n");break; } case 2:printf("x=2\n"); } }
第3题:
以下程序的输出结果是【 】。
include <stdio.h>
main()
{ int j,a[]={1,3,5,7,9,11,13,15},*P=a+5;
for(j=3; j;j-)
{ switch(i)
{ case 1:
case 2: printf("%d",*p++); break;
case 3: printf("%d",* (-p));
}
}
}
第4题:
以下程序的输出结果是( )。
include<stdio.h>
void fun(int x)
{ if(x/2>0)fun(x/2);
printf("%d",x);
}
main()
{fun(3);printf("\n");
}
第5题:
有以下程序: #include <stdio. h> main( ) { unsigned int a; int b=-1; a=b; printf(" % u", a);程序运行后的输出结果是( )。
A.-1
B.65535
C.32767
D.-32768
第6题:
以下程序运行后的输出结果是( )。
include<stdio.h>
main()
{ int x=20;
printf("%d", 0<x<20);
printf("%d\n", 0<x && x<20);
}
第7题:
以下程序的输出结果是【 】。
include<stdio.h>
main()
{ struct stru
{ int a;
float b;
char d[4];
};
printf("%d\n",sizeof(struct stru));
}
第8题:
下面的程序在编泽时产生错误,其出错原因是( )。 #include<stdio.h> main() {int 1_case;float printF; printf("请输入2个数:"); scanf ("%d%f",&1_case,&printF); printf("%d%f\n",1_case,printF); }
A.定义语句出错,1_case不能作为变量名
B.定义语句出错,printF不能用作用户自定义标识符
C.定义语句无错,scanf不能作为输入函数使用
D.定义语句无错,printf不能输出1_case的值
第9题:
阅读以下程序
#include<stdio,h>
main( )
{ int case;float printF;
printf(“请输入2个数:”);
scanf(“%d%f”,&zase,&rintF);
prinff(“%d%f\n”,case,printF);
}
该程序在编译时产生错误,其出错原因是
A.定义语句出错,ca8e是关键字,不能用作用户自定义标识符
B.定义语句出错,pfintF不能用作用户自定义标识符
C.定义语句无错,scanf不能作为输入函数使用
D.定义语句无错,printf不能输出case的值
第10题:
若有以下定义:float x;int a,b,c=2;,则正确的switch语句是( )
A.switch(x) { case 1.0:printf("*\n"); case 2.0:printf("**\n"); }
B.switch(int(x)) { case 1:printf("*\n"); case 2:printf("**\n"); }
C.switch(a+b) { case 1:printf("*\n"); case 1+2:printf("**\n"); }
D.switch(a+B){ case 1:printf("*\n"); case c:printf("**\n"); }
第11题:
有以下程序: #include<stdio.h> main() { int a=6,b=7,m=1; switch(a%2) { case 0:m++;break; case 1 :m++; switch(b%2) { defaut:m++; case0:m++;break; } } printf("%d\n",m); }
A.1
B.2
C.3
D.4
第12题:
第13题:
请阅读以下程序: #include<stdio.h> main() { int x=1,y=0,a=0,b=0; switch(x) { case 1: switch(y) { case 0:a++;break;} case 2: a++,b++;break;} printf("a=%d,b=%d\n",a,b); 上面程序的输出结果是
A.a=2,b=1
B.a=1,b=1
C.a=1,b=0
D.a=2,b=2
第14题:
#include "stdio.h"void half(void *pval,char type);main(){ int i=20; long l=100000; float ff=12.456; double d=123.044444; printf("%d\n",i); printf("%ld\n",l); printf("%f\n",ff); printf("%lf\n",d); half(&i,'i'); half(&l,'l'); half(&ff,'ff'); half(&d,'d'); printf("\n%d",i); printf("\n%ld",l); printf("\n%f",ff); printf("\n%lf",d); return 0; }void half(void *pval,char type){ switch(type) { case 'i': { *((int *)pval)/=2; //我想问一下,这个语法怎么理解,太复杂了 break; } case 'l': { *((long *)pval)/=2; break; } case 'ff': { *((float *)pval)/=2; break; } case 'd': { *((double *)pval)/=2; break; } } }
第15题:
以下程序的运行结果是( )。
main()
(int a=2,b=7,c=5;
switch(a>0)
{case 1:switch(b<0)
{case 1:switch(");break;
case 2:printf("!");break;
}
case 0:switch(c==5)
{case 0:printf("*");break;
case 1:printf("");break;
case 2:printf("$");break;
}
default:printf ("&");
}
printf("\n");
}
第16题:
有以下程序: #include <stdio.h> main ( ) int i; for(i =0;i <3 ;i ++ ) switch (i) case 0: printf(" % d" ,i); case 2: printf(" % d" , i); default: printf( "% d" , i);程序运行后的输出结果是( )。
A.22111
B.21021
C.122
D.12
第17题:
以下程序的输出结果是( )。 #include <stdio.h> main() { int i; for(i=1;i<5;i++) { if(i%2) printf("*"); else continue; printf("#"); } printf("$\n");
A.*#*#*#$
B.#*#*#*$
C.*#*#$
D.#*#*$
第18题:
以下程序的功能是:将输入的正整数按逆序输出。例如:若输入135则输出531。请填空。
include <stdio.h>
main()
{ int n, s;
printf("Enter a number:"); scanf("%d",&n);
printf("Output: ");
do
{ s=n%10; printf("%d",s); [ ]; }
while (n!=0);
printf("\n');
}
第19题:
针对一下C语言程序,请按要求回答问题。
已知weekday. c源程序如下:
include<stidio. h>
include<conio. h>
/ *主函数* /
Int main()
{
Char letter;
Printf("please input the first letter,"Y'to exit!\n");
While((letter=getch())!="Y")//当输入字母为Y时结束
{
Switch(letter)
{
Case'S':
Printf("%c\n",letter);
Printf("please input second letter\n");//输入第二个字母
If((letter=getch())=='a')
Printf("Saturday\n");
Else if(letter=='u')
Printf("Sunday\n");
Else printf('data error\n);
Break;
Case'F':
Printf("fridaykn");
Break;
Case 'M':
Printf("mondayha");
Break;
Case 'T':
Printf("%c\n",letter);
Printf("please input second letter\a");//输入第二个字母
If((letter=getch())=='u')
Printf("Tuesday\n"):
Else if(letter=='h')
Printf("Thursday\n");
Break;
Case 'W':
Printf("Wednesday\n");
}
}
Return 0;
}
(1) 画出主函数main的控制流程图;
(2) 设计一组测试用例,使main函数的语句覆盖率尽量达到100%;
(3) Main函数的语句覆盖率能否达到100%?如果认为无法达到,需说明原因。
第20题:
执行下面程序的正确结果是 ( ) main() {float a=1.9 switch(A) { case 0:printf("0000"); case 1:printf("1111"); case 2:printf("3333"); } printf("%f",A) ; }
A.1.900000
B.111133331.900000
C.33331.900000
D.00001111233331.900000
第21题:
阅读以下程序: #include<stdio.h> main( ) {int case;float printF; printf("请输人2个数:"); scanf("%d%fl"&case,&printF); printf("%d ofof\n",case,printF); } 该程序在编译时产生错误,其出错原因是( )。
A.定义语句出错,case是关键字,不能用做用户自定义标识符
B.定义语句出错,printF不能用做用户自定义标识符
C.定义语句无错,scanf不能作为输入函数使用
D.定义语句无错,printf不能输出case的值
第22题:
有以下程序: #include < stdio. h > main ( ) int a=3,b=4,c=5,d=2; if(a>b) if(b>c)printf("%d",d++ +1); else printf( "% d", + + d + 1 ); printf( "% d \n" ,d); 程序运行后的输出结果是( )。
A.2
B.3
C.43
D.44
第23题:
请阅读以下程序: #include<stdio.h> main() { int x=1,y=0,a=0,b=0; switch(x) { case 1: switch(y) { case 0:a++;break; case 2: a++,b++;break;} printf("a=%d,b=%d\n" ,a,b); 上面程序的输出结果是( )。
A.a=2,b=1
B.a=1,b=1
C.a=1,b=0
D.a=2,b=2