C语言程序设计作业2答案.docVIP

  • 127
  • 0
  • 约8.22千字
  • 约 10页
  • 2017-02-09 发布于重庆
  • 举报
C语言程序设计作业2答案

C语言程序设计第2次作业答案      单项选择题答案 1B 2B 3D 4C 5B 6B 7D 8D 9B 10C 11C 12B 13A 14C 15B 16B 17D 18A 19D 20B 单项选择题 1.若有以下定义: int a[]={3, 4, 5, 6, 7, 8, 9, 10, 11}, *p=a; 则值为5的表达式是( )。 A)p+=5, *(p+1) B)p+=1, * ++p C)p+=4, *p++ D)p+=1, ++ *p 2.下面函数调用语句含有实参的个数为() fun( ( a, b, c, d ), ( m, n ), (f, g ) ); A)1 B)3 C)4 D)2 3.函数形式正确的是()。 A) double myfun( int x, int y) B) int myfun( int x, y) { m=x+y; return m; } { int m; } C) int myfun( int x, int y) D) int myfun( int x, int y) { int x, y; double m; { int m; m=x+y; return m; } m=x+y; return m; } 4.不正确的字符串赋值或赋初值方式是()。 A)char *str; str=”string”; B)char str[7]={‘s’, ‘t’, ‘r’, ‘i’, ‘n’, ‘g’} C) char str[10]; str=”string”; D)char str[]=”string”; str2[]=; strcpy(str2, str1); 5.以下程序的输出结果是()。 #include stdio.h main() { char str[]=SSSWLIA, c; int k; for (k=2; (c=str[k])!=\0; k++) { switch (c) { case I: ++k; break; case L: continue; default: putchar(c); continue; } } putchar(*); } A)SSW* B)SW* C)SW*A D)SW 6.以下程序的输出结果是()。 #include stdio.h int w=3; fun( int k) { if ( k==0) return w; return ( fun(k -1 )*k); } main() { int w=10; printf(%d\n, fun(5)*w); } A)360 B)3600 C)1080 D)1200 7. 以下程序的输出结果是()。 #include stdio.h int w=3; f( int a) { int b=0; static int c=3; b++; c++; return ( a+b+c); } main() { int a=2, i; for (i=0; i3; i++) printf(%d , f(a)); } A)7 7 7 B)7 10 13 C)7 9 11 D)7 8 9 8.以下程序的输出结果是()。 #include stdio.h main() { int a[]={1,2,3,4,5,6}, *p; p=a; *(p+3)+=2; printf(%d, %d \n , *p, *(p+3)); } A)0, 5 B)1, 5 C)0, 6 D)1, 6 9.以下程序的输出结果是()。 #include stdio.h #define PT 5.5 #define S(x) PT*x*x main() { int a=1, b=2; printf(%4.1f\n , S(a+b)); } A)49.5 B)9.5 C)12.5 D)33.5 10.下面程序段的输出结果是()。 #include stdio.h #define LETTER 1 main() { char str[20]=Language, c; int i=0; while (( c=str[i])!=\0) { i++; # if (LETTER) if (c=a c=z) c=c-32; #els

文档评论(0)

1亿VIP精品文档

相关文档