c语言高级面试题.doc
《c语言高级面试题.doc》由会员分享,可在线阅读,更多相关《c语言高级面试题.doc(21页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、整个测试遵循以下的约定: 假定在所有的程序中必须的头文件都已经被正确包含。考虑如下的数据类型: char 为 1 个字节 int 为 4 个字节 long int 为 4 个字节 float 为 4 个字节 double 为个 8 字节 long double 为 8 个字节 指针为 4 个字节1. Consider the following program:#includestatic jmp_buf buf;main()volatile int b;b =3;if(setjmp(buf)!=0) printf(“%d “, b); exit(0);b=5;longjmp(buf , 1)
2、;The output for this program is: (a) 3 (b) 5 (c) 0 (d) None of the above2. Consider the following program:main()struct node int a;int b;int c; ;struct node s= 3, 5,6 ;struct node *pt = printf(“%d“ , *(int*)pt);The output for this program is: (a) 3 (b) 5 (c) 6 (d) 73. Consider the following code segm
3、ent:int foo ( int x , int n)int val;val =1;if (n0) if (n%2 = 1) val = val *x;val = val * foo(x*x , n/2);return val;What function of x and n is compute by this code segment? (a) xn (b) x*n (c) nx (d) None of the above4. Consider the following program:main()int a5 = ;int *ptr = (int*)(printf(“%d %d“ ,
4、 *(a+1), *(ptr-1) );The output for this program is: (a) 2 2 (b) 2 1 (c) 2 5 (d) None of the above 5. Consider the following program:void foo(int 3 ); main()int a 33= 1,2,3 , 4,5,6,;foo(a);printf(“%d“ , a21);void foo( int b3)+ b;b11 =9;The output for this program is: (a) 8 (b) 9 (c) 7 (d) None of the
5、 above6. Consider the following program:main()int a, b,c, d;a=3;b=5;c=a,b;d=(a,b);printf(“c=%d“ ,c);printf(“d=%d“ ,d);The output for this program is: (a) c=3 d=3 (b) c=5 d=3 (c) c=3 d=5 (d) c=5 d=57. Consider the following program:main()int a3 = 1,2,3 ,4,5,6;int (*ptr)3 =a;printf(“%d %d “ ,(*ptr)1,
6、(*ptr)2 );+ptr;printf(“%d %d“ ,(*ptr)1, (*ptr)2 );The output for this program is: (a) 2 3 5 6 (b) 2 3 4 5 (c) 4 5 0 0 (d) None of the above8. Consider following functionint *f1(void)int x =10;return(int *f2(void)int*ptr;*ptr =10;return ptr;int *f3(void)int *ptr;ptr=(int*) malloc(sizeof(int);return p
7、tr;Which of the above three functions are likely to cause problem with pointers (a) Only f3 (b) Only f1 and f3 (c) Only f1 and f2 (d) f1 , f2 ,f39. Consider the following program:main()int i=3;int j;j = sizeof(+i+ +i);printf(“i=%d j=%d“, i ,j);The output for this program is:(a) i=4 j=2 (b) i=3 j=2 (
8、c) i=3 j=4 (d) i=3 j=610. Consider the following program:void f1(int *, int); void f2(int *, int); void(*p2) ( int *, int);main()int a;int b;p0 = f1;p1 = f2;a=3;b=5;p0(printf(“%dt %dt“ , a ,b);p1(printf(“%dt %dt“ , a ,b);void f1( int* p , int q)int tmp;tmp =*p;*p = q;q= tmp;void f2( int* p , int q)i
9、nt tmp;tmp =*p;*p = q;q= tmp; The output for this program is: (a) 5 5 5 5(b) 3 5 3 5 (c) 5 3 5 3 (d) 3 3 3 311. Consider the following program:void e(int ); main()int a;a=3;e(a);void e(int n)if(n0)e(-n);printf(“%d“ , n);e(-n);The output for this program is: (a) 0 1 2 0(b) 0 1 2 1 (c) 1 2 0 1 (d) 0 2
10、 1 112. Consider following declarationtypedef int (*test) ( float * , float*)test tmp;type of tmp is (a) Pointer to function of having two arguments that is pointer to float (b) int (c) Pointer to function having two argument that is pointer to float and return int (d) None of the above 13. Consider
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 高级 试题
限制150内