c语言高级试题,c语言高级面试题.doc

c语言高级面试题

整个测试遵循以下的约定:

??????? 假定在所有的程序中必须的头文件都已经被正确包含。

考虑如下的数据类型:

??????? char 为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

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 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 (n>0)

{

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) x^n(b) x*n(c) n^x(d) None of the above

4. Consider the following program:

main()

{

int a[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 following program:

void foo(int [][3] );

?

main()

{

int a [3][3]= { { 1,2,3} , { 4,5,6},};

foo(a);

printf("%d" , a[2][1]);

}

?

void foo( int b[][3])

{

++ b;

b[1][1] =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 this program is: (a) c=3 d=3(b) c=5 d=3(c) c=3 d=5(d) c=5 d=5

7. Consider the following program:

main()

{

int a[][3] = { 1,2,3 ,4,5,6};

int (*ptr)[3] =a;

?

printf("%d %d " ,(*ptr)[1], (*ptr)[2] );

?

++ptr;

printf("%d %d" ,(*ptr)[1], (*ptr)[2] );

}

The output for this program is:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值