文档详情

C语言2016下半年第二次作业.doc

发布:2017-05-17约7.45千字共11页下载文档
文本预览下载声明
  C语言程序设计第次作业; } { 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.不正确的字符串赋值或赋初值方式是( C )。 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.以下程序的输出结果是( B )。 #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.以下程序的输出结果是( B )。 #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. 以下程序的输出结果是( D )。 #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.以下程序的输出结果是( D )。 #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.以下程序的输出结果是( B )。 #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.下面程序段的输出结果是( C )。 #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; #else if (c=A c=Z) c=c+32; #endif printf(%c, c); } } A)Language B)language C)LANGUAGE D)lANGUAGE 11.若有说明:char *s[]={“FORTRAN”, “BASIC”,”PASCAL”,”JAVA”,”C”}; 则表达式 *s[1]*s[3]比较的是( C )。 A)字符F和字符P B)字符串BASIC和字符串JAVA C)字符B和字符J D)字符串FORTRAN和字符串PASCAL 12.如下程序的输出结果是( B )。 #include stdio.h main() { char a[20]=chinese ; char *p=a; for (; pa+7; p+=2) pu
显示全部
相似文档