c语言1

  • 格式:doc
  • 大小:46.00 KB
  • 文档页数:11

一、选择题(1) 在C语言中,如果下面的变量都是int类型,则输出的结果是csum=pad=5; pad=sum + + ,pad + + , + + pad;printf("%d\n",pad); A) 7 B) 6 C) 5 D) 4(2) 以下程序的输出结果是b# include <stdio.h>main(){ int i=010 , j = 10;printf("%d,%d\n",+ +i , j - -); } A) 11,10 B) 9,10 C) 010,9 D) 10,9(3) 已知在ASCII代码中,字母A的序号为65,以下程序的输出的结果是# include <stdio.h>main(){ char c1='A', c2='Y';printf("%d,%d\n",c1,c2); }A) 因输出格式不合法,输出错误信息B)65,90 C)A,Y D)65,89(4) 指针s所指字符串的长度为char *s="\\"Name\\Address\n";A) 19 B) 15 C) 18 D)说明不合法(5) 设有说明int(*ptr)[m];其中的标识符ptr是A)M个指向整型变量的指针B)指向M个整型变量的函数指针C)一个指向具有M个整型元素的一维数组的指针D)具有M个指针元素的一维指针数组,每个元素都只能指向整型量(6) 语句while(!E);中的条件!E等价于A)E = = 0 B)E!=1 C)E!=0 D)~E(7) 以下程序的输出结果是# include <stdio.h>main(){ printf("%d\n",NULL); } A) 不确定的(因变量无定义)B)0 C)-1 D)1 (8) 以下函数调用语句中含有的实参个数为。

func((exp1,exp2),(exp3,exp4,exp5)); A) 1 B) 2 C) 4 D) 5(9) 设有以下语句:char a=3,b=6,c;c=a^b<<2;则c的二进制值是A) 00011011 B)00010100 C)00011100 D)00011000 (10) 下面的程序中第几行有错误(每行程序前面的数字是行号)。

1 #include <stdio.h>2 main()3 {4 float a[3]={0,0};5 int i;6 for(i=0;i<3;i + + ) scanf("%d",&a[i]);7 for(i=1;i<3;i + + ) a[0]=a[0]+a[i];8 printf("%f\n",a[0]);9 } A) 没有B)第4行C)第6行D)第8行(11) 设有语句int a=3;则执行了语句a+=a-=a*a;后,变量a的值是A)3 B)0 C)9 D)-12(12) 以下的for循环for(x=0,y=0; (y!=123)&&(x<4); x + + );A) 是无限循环B)循环次数不定C)执行4次D)执行3次(13) 设有语句char a='\72';则变量aA)包含1个字符B)包含2个字符C)包含3个字符D)说明不合法(14) 以下程序的输出结果是# include <stdio.h># include <math..h>main(){ int a=1,b=4,c=2;float x=10..5 , y=4.0 , z;z=(a+b)/c+sqrt((double)y)*1.2/c+x;pritnf("%f\n",z); }A) 14.000000 B) 015.400000 C) 13.700000 D) 14.900000(15) sizeof(double)是A)一种函数调用B)一个双精度型表达式C)一个整型表达式D)一个不合法的表达式(16) C语言中A)不能使用do-while语句构成的循环B)do-while语句构成的循环必须用break语句才能退出C)do-while语句构成的循环,当while语句中的表达式值为非零时结束循环D)do-while语句构成的循环,当while语句中的表达式值为零时结束循环(17) 以下程序的输出结果是# 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(18) 以下程序的输出结果是# include <stdio.h>main(){ int a=2,c=5;printf("a=%%d,b=%%d\n",a,c); }A) a=%2,b=%5 B) a=2,b=5 C) a=%%d,b=%%d D) a=%d,b=%d(19) 以下程序的输出结果是# include<stdio.h>main(){ int a ,b,d=241;a=d/100%9;b=(-1)&&(-1);printf("%d,%d\n",a,b); }A) 6,1 B) 2,1 C) 6,0 D) 2,0(20) 以下程序的输出结果是# 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) #*#*$(21) 以下for语句构成的循环执行了多少次# include <stdio.h># define N 2# define M N+1# define NUM (M+1)*M/2main(){ int i , n=0;for ( i=1;i<=NUM;i + + );{n + + ; printf("%d",n); }printf("\n"); } A) 5 B) 6 C) 8 D) 9(22) 设有以下语句,则不是对a数组元素的正确引用的选项是(其中0≤i<10)int a[10]={0,1,2,3,4,5,6,7,8,9}, *p=a; A) a[p-a] B) *(&a[i]) C) p[i] D) *(*(a+i)) (23) 有以下程序:# include <stdio.h># define N 6main(){ char c[N]; int i=0;for ( ;i<N ; c[i]=getchar () , i + + );for ( i=0 ; i<N ; putchar(c[i]) , i + + ); }输入以下三行,每行输入都是在第一列上开始,<CR>代表一个回车符:a<CR>b<CR>cdef<CR>程序的输出结果是A) abcdef B) a C) a D) ab b bc cd cdefdef(24) 以下程序调用findmax函数求数组中值最大的元素在数组中的下标,请选择填空。

# include <stdio.h>findmax ( s , t , k )int *s , t , *k;{ int p; for(p=0,*k=p;p<t;p + + )if ( s[p] > s[*k] )_________; }main(){ int a[10] , i , k ;for ( i=0 ; i<10 ; i + + ) scanf("%d",&a[i]);findmax ( a,10,&k );printf ( "%d,%d\n" , k , a[k] ); } A) k=p B) *k=p-s C) k=p-s D) *k=p(25) 有以下程序:#include<stdio.h>union pw{ int i; char ch[2]; } a;main(){ a.ch[0]=13; a.ch[1]=0; printf("%d\n",a.i); }程序的输出结果是(注意:ch[0]在低字节,ch[1]在高字节。

)A) 13 B) 14 C) 208 D) 209(26) 有以下程序:# include<stdio.h>main(){ int c;while((c=getchar())!='\n'){ switch(c-'2'){ case 0:case 1: putchar(c+4);case 2: putchar(c+4);break;case 3: putchar(c+3);case 4: putchar(c+2);break; } }printf("\n"); }从第一列开始输入以下数据,<CR>代表一个回车符。

2743<CR>程序的输出结果是A) 668977 B) 668966 C) 6677877 D) 6688766 (27) 以下程序的输出结果为main(){ char *alpha[6]={"ABCD","IJKL","MNOP","QRST","UVWX"};char **p; int i;p=alpha;for(i=0;i<4;i + + ) printf("%s",p[i]); printf("\n"); }A) ABCDEFGHIJKL B) ABCD C) ABCDEFGHIJKLMNOP D) AEIM(28) 以下程序的输出结果是# include<stdio.h># define FUDGE(y) 2.84+y# define PR(a) printf("%d",(int)(a))# define PRINT1(a) PR(a);putchar('\n')main(){int x=2; PRINT1(FUDGE(5)*x); } A) 11 B) 12 C) 13 D) 15(29) 以下程序的输出结果是# include<stdio.h>main(){ int i=1,j=3;printf("%d",i + + );{ int i=0; i+=j*2; printf("%d,%d",i,j); }printf("%d,%d\n",i,j); } A) 1,6,3,1,3 B) 1,6,3,2,3 C) 1,6,3,6,3 D) 1,7,3,2,3 (30) 以下程序的输出结果是# include <stdio.h>main(){ int k=4,m=1,p;p=func(k,m); printf("%d,",p); p=func(k,m); printf("%d\n",p);}func(a,b)int a,b;{ static int m=0,i=2;i+=m+1; m=i+a+b; return(m); } A) 8,17 B) 8,16 C) 8,20 D) 8,8 (31) 设有以下语句:char str[4][12]={"aaa","bbbb","ccccc","dddddd"},*strp[4];int i;for(i=0;i<4;i + + )strp[i]=str[i];不是对字符串的正确引用的选项是(其中0≤k<4)A) strp B) str[k] C) strp[k] D) *strp(32) 设有以下语句:char str1[]="string",str2[8],*str3,*str4="string";则不是对库函数strcpy的正确调用的选项是(库函数用于复制字符串)A) strcpy(str1,"HELLO1"); B) strcpy(str2,"HELLO2");C) strcpy(str3,"HELLO3"); D) strcpy(str4,"HELLO4");(33) C语言中形参的缺省存储类别是A)自动(auto) B)静态(static) C)寄存器(register) D)外部(extern) (34) 设有以下语句:struct st {int n; struct st *next;};static struct st a[3]={5,&a[1],7,&a[2],9,'\0'},*p;p=&a[0];则下列哪一个表达式的值是6A)p + + ->n B) p->n + + C) (*p).n + + D) + + p->n(35) 以下四个程序中,哪一个不能对两个整型变量的值进行交换A)# include <stdio.h>main(){ int a=10,b=20; swap(&a,&b);printf("%d %d\n",a,b);}swap(p,q)int *p,*q;{int *t;t=(int )malloc(sizeof(int)); t=p;*p=*q;*q=*t; }B) # include <stdio.h> main(){int a=10,b=20;swap(&a,&b);printf("%d %d\n",a,b);}swap(p,q)int p,q;{int *t;t=*p;*p=*q;*q=t;}C) # include <stdio.h> main(){ int *a,*b;*a=10,*b=20;swap(a,b);printf("%d %d\n",*a,*b); }swap(p,q)int *p,*q;{int t;t=*p;*p=*q;*q=t;} D) # include<stdio.h> main(){int a=10,b=20;int x=&a,y=&b;printf("%d %d\n",a,b);}swap(p,q)int *p,*q;{int t;t=*p;*p=*q;*q=t;} 二、填空题(1)以下C语言程序将磁盘中的一个文件复制到另一个文件中,两个文件名在命令行中给出。