高级C语言程序员测试必过的十六道最佳题 面试题.pdf

上传人:asd****56 文档编号:70335710 上传时间:2023-01-19 格式:PDF 页数:12 大小:154KB
返回 下载 相关 举报
高级C语言程序员测试必过的十六道最佳题 面试题.pdf_第1页
第1页 / 共12页
高级C语言程序员测试必过的十六道最佳题 面试题.pdf_第2页
第2页 / 共12页
点击查看更多>>
资源描述

《高级C语言程序员测试必过的十六道最佳题 面试题.pdf》由会员分享,可在线阅读,更多相关《高级C语言程序员测试必过的十六道最佳题 面试题.pdf(12页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究 博客首页 注册 建议与交流 排行榜 加入友情链接 推荐 投诉 搜索:帮助 管理博客 发表文章 留言 收藏夹 博客圈 音乐 相册 文章 首页 关于作者 姓名:小寿职业:研究生在读年龄:24位置:北京 QQ :154793677个性介绍:arm+linux学习!欢迎加入我的qq群:56641716说明:本Blog仅供学习之用,转载文章如涉及版权,请通知。原创作品如转载,请注明出处。|我的分类 转高级C语言程序员测试必过的十六道最佳题目+答案详解 假定在所有的程序中必须的头文件都已经被正确包含。考虑如下的数据类型:char

2、为1个字节 int为4个字节 long int为4个字节 float为4个字节 double为个8字节 long double为8个字节 指针为4个字节1、Consider the following program:#include static jmp_buf buf;main()volatile int b;b=3;if(setjmp(buf)!=0)printf(%d,b);exit(0);b=5;longjmp(buf,1);The output for this program is:(a)3 (b)5 (c)0 (d)None of the above file:/C|/Docu

3、ments and Settings/Administrator/桌面/转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究.htm(第 112 页)2008-4-14 16:15:48搜索转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究2、Consider the following program:main()struct node int a;int b;int c;struct node s=3,5,6;struct node*pt=&s;printf(%d,*(int*)pt);The output for this program

4、 is:(a)3 (b)5 (c)6 (d)7 3、Consider the following code segment: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:file:/C|/Documents

5、 and Settings/Administrator/桌面/转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究.htm(第 212 页)2008-4-14 16:15:48转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究main()int a5=1,2,3,4,5;int*ptr=(int*)(&a+1);printf(%d%d,*(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 fo

6、llowing program:void foo(int 3);main()int a 33=1,2,3,4,5,6,7,8,9;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 above 6、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 thi

7、s program is:(a)c=3 d=3 (b)c=5 d=3 file:/C|/Documents and Settings/Administrator/桌面/转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究.htm(第 312 页)2008-4-14 16:15:48转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究(c)c=3 d=5 (d)c=5 d=5 7、Consider the following program:main()int a3=1,2,3,4,5,6;int(*ptr)3=a;printf(%d%d ,(*p

8、tr)1,(*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 above 8、Consider following function:int*f1(void)int x=10;return(&x);int*f2(void)int*ptr;*ptr=10;return ptr;int*f3(void)int*ptr;ptr=(int*)malloc(sizeof(int);return ptr;Which

9、 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,f3 9、Consider the following program:file:/C|/Documents and Settings/Administrator/桌面/转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究.htm(第 412 页)2008-4-14 16:15:48转高级C语言程序员测试必过的十六道最

10、佳题目+答案详解-面试题-linux研究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 (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(&a,b);printf(%dt%d

11、t,a,b);p1(&a,b);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)int 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 3 file:/C|/Documents and Settings/Administrator/桌面/转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究.htm(第 512

12、页)2008-4-14 16:15:48转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究11、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 1 1 12、Consider following declarationtypedef int(*test)(floa

13、t*,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 the following program:main()char*p;char buf10=1,2,3,4,5,6,9,8;p=(buf+1)

14、5;printf(%d,p);The output for this program is:(a)5 (b)6 file:/C|/Documents and Settings/Administrator/桌面/转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究.htm(第 612 页)2008-4-14 16:15:48转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究(c)9 (d)None of the above 14、Consider the following program:Void f(char*);main()char*arg

15、v=ab,cd,ef,gh,ij,kl;f(argv);void f(char*p)char*t;t=(p+=sizeof(int)-1;printf(%s,t);The output for this program is:(a)ab (b)cd (c)ef (d)gh 15、Consider the following program:#include int ripple(int,.);main()int num;num=ripple(3,5,7);printf(%d,num);int ripple(int n,.)int i,j;int k;va_list p;k=0;j=1;va_s

16、tart(p,n);for(;jn;+j)i=va_arg(p,int);for(;i;i&=i-1 )+k;return k;The output for this program is:(a)7 file:/C|/Documents and Settings/Administrator/桌面/转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究.htm(第 712 页)2008-4-14 16:15:48转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究(b)6 (c)5 (d)3 16、Consider the following pro

17、gram:int counter(int i)static int count=0;count=count+i;return(count);main()int i,j;for(i=0;i 0)if(n%2=1)product=product*val;n=n/2;val=val*val;/*Code raise a number(x)to a large power(n)using binary doubling strategy*/Algorithm description(while n0)if next most significant binary digit of n(power)is

18、 one then multiply accumulated product by current val,reduce n(power)sequence by a factor of two using integer division.get next val by multiply current value of itself Answer 4.The answer is(c)type of a is array of int type of&a is pointer to array of int Taking a pointer to the element one beyond

19、the end of an array is sure to work.Answer 5.The answer is(b)Answer 6.The answer is(c)The comma separates the elements of a function argument list.The comma is also used as an operator in comma expressions.Mixing the two uses of comma is legal,but you must use parentheses to distinguish them.the lef

20、t operand E1 is evaluated as a void expression,then E2 is evaluated to give the result and type of the comma expression.By recursion,the expression E1,E2,.,En results in the left-file:/C|/Documents and Settings/Administrator/桌面/转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究.htm(第 912 页)2008-4-14 16:15:48转高级

21、C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究to-right evaluation of each Ei,with the value and type of En giving the result of the whole expression.c=a,b;/*yields c=a*/d=(a,b);/*d=b */Answer 7.The answer is(a)/*ptr is pointer to array of 3 int*/Answer 8.The answer is(c)f1 and f2 return address of local variab

22、le,when function exit local variable disappeared Answer 9.The answer is(c)sizeof operator gives the number of bytes required to store an object of the type of its operand.The operands is either an expression,which is not evaluated(+i+i)is not evaluated so i remain 3 and j is sizeof int that is 2)or

23、a parenthesized type name.Answer 10.The answer is(a)void(*p2)(int*,int);define array of pointer to function accept two argument that is pointer to int and return int.p0=f1;p1=f2 contain address of function.function name without parenthesis represent address of function Value and address of variable

24、is passed to function only argument that is effected is a(address is passed).Because of call by value f1,f2 can not effect b Answer 11.The answer is(a)Answer 12.The answer is(c)C provide a facility called typedef for creating new data type names,for example declarationtypedef char stringMakes the na

25、me string a synonym for int.The type string can be used in declaration,cast,etc,exactly the same way that the type int can be.Notice that the type being declared in a typedef appears in the position of a variable name not after the word typedef.Answer 13.The answer is(c)file:/C|/Documents and Settin

26、gs/Administrator/桌面/转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究.htm(第 1012 页)2008-4-14 16:15:48转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究If the type of an expression is array of T for some type T,then the value of the expression is a pointer to the first object in the array,and the type of the expression is

27、altered to pointer to T So(buf+1)5 is equvalent to*(buf+6)or buf6 Answer 14.The answer is(d)p+=sizeof(int)point to argv2 (p+=sizeof(int)-1 points to argv1 Answer 15.The answer is(c)When we call ripple value of the first argument passed to ripple is collected in the n that is 3.va_start initialize p

28、to point to first unnamed argument that is 5(first argument).Each call of va_arg return an argument and step p to the next argument.va_arg uses a type name to determine what type to return and how big a step to take Consider inner loop(;i;i&=i-1)k+/*count number of 1 bit in i*in five number of 1 bit

29、s is(101)2 in seven number of 1 bits is(111)3 hence k return 5example let i=9=1001 i-1 =1000 (i-1)+1=i 1000 +1 1 001The right most 1 bit of i has corresponding 0 bit in i-1 this way i&i-1,in a two complement number system will delete the right most 1 bit I(repeat until I become 0 gives number of 1 b

30、its)Answer 16.The answer is(b)Static variable count remain in existence rather than coming and going each time function is called so first call counter(0)count=0 second call counter(1)count=0+1;third call counter(2)count=1+2;/*count=count+i*/fourth call counter(3)count=3+3;fifth call counter(4)count

31、=6+4;file:/C|/Documents and Settings/Administrator/桌面/转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究.htm(第 1112 页)2008-4-14 16:15:48转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究 sixth call counter(5)count=10+5;原文地址 http:/s%20s/发表于:2008-03-06,修改于:2008-03-06 10:44,已浏览87次,有评论0条 推荐 投诉 网友评论 发表评论 file:/C|/Documents and Settings/Administrator/桌面/转高级C语言程序员测试必过的十六道最佳题目+答案详解-面试题-linux研究.htm(第 1212 页)2008-4-14 16:15:48

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 技术资料 > 其他杂项

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com