上海一家外企的面试题

22. In C, which of following definitions is correct in defining an array of pointers, with each item
of this array being a pointer to function like

int func(int *)?

A. int (*p[20])(int *)
B. int (*p)(int *)[20]
C. int (*p)(int *[20])
D. int *(*p[20])(int *);
E. None of the above.


23. In little-endian systems, what is the result of following C program?

typedef struct bitstruct{

int b1:5;

int :2;

int b2:2;

}bitstruct;

void main(){

bitstruct b;

memcpy(&b,”EMC EXAMINATION”,sizeof(b));

printf(“%d,%d/n”, b.b1, b.b2);

}

24. In IA-32 systems, what is the result of following C program?

#define MAX 255

int main(){

unsigned char A[MAX+1],i;

for(i=0;i <=MAX;i++)



A[i]=i;

printf(“%d/n”,A[0]);

Return 0;

}

A. 0
B. 255
C. 256
D. The program won’t return and will print nothing
E. Compile error.


25. What is the result of following C program?

int inc(int a){

return (++a);

}

typedef int (*FUNC1) (int in);

int multi(int *a, int *b, int *c){

return (*c=*a**b);

}

typefef int (FUNC2) (int *, int *, int *);

void show(FUNC2 fun, int arg1, int *arg2){

FUNC1 p=&inc;

int temp=p(arg1);

printf(“%d/n”,*arg2);

}

Main(){

Int a;

Show(multi,10,&a);

Return 0;

}

A.. 100

B. 110

C. 120

D. 130

E. None of the above

26. What will the following C function f2() print?

void f1(char *s,.char *t){

if(*s==’/0’) return;

*t=*s;

f1(++s,++t);

}

void f2(){

char *s1=”The C Programming Language is good”;

char *s2=”The C Programming Language”;

char *t=(char *)malloc(strlen(s1)+1);

memset(t,0,strlen(s1)+1);



f1(s1,t);

f1(s2,5);

printf(“%s/n”,t);

}

A. egaugnaL gnimmargorP C ehT
B. The C Programming Language
C. 27
D. Doog si egaugnaL gnimmargorP C ehT
E. The C Programming Language is good


27. In C++, Class A is defined simply as:

Class A{};

What is results of calling sizeof(A)?

A. 0
B. 1
C. 4
D. 64
E. None of the above


28. What will the following C++ function print?

int func()

{

float a=1.0f;

cout < <boolalpha < <( (int)a==(int &)a ) < <” ”;

float b=0.0f;

cout < <boolalpha < <( (int)b==(int &)b ) < <endl;

}

A. true true
B. false false
C. true false
D. false true
E. None of the above


29. Four people are in a group

Alice says,”Exactly one of us is lying.”

Bob says, ”Exactly two of us are lying.”

Charles says, “Exactly three of us are lying.”

Dick says, “All four of us are lying.”

How many people in this group are lying?

A. 0
B. 1
C. 2
D. 3
E. 4

30. Allen and Brenda, both have a note stuck on their forehead, with a positive integer number
written on it .Both Allen and Brenda can see each other’s number. They also know that the two
numbers have a difference of one. They are trying to figure out the number on their own forehead.



Allen first says,”I don’t know my number.”

Brenda says,” I don’t know my number either”

Then Allen says “Now, I know my number”

Brenda now says, “Yeah, I know my number also!”

What is the number of Allen and Brenda?

A. 2,1
B. 1,2
C. 3,2
D. 2,3
E. 4,3


31. The traveling gropu will consist of exactly three members to be selected from the seven pepole:
A,B,C,D,E,F and G. The selection will be done according to the following conditiions:

* Neither A nor B can be in the group unless the other is also in the group.

*If C is in the group, the D must be in the group

*E and F cannot sboth be in the group

* If G is in the group, then A cannot be in the group

Which of following is the travelling group?

A. (C,E,G)
B. (D,E,G)
C. (C,D,A)
D. (E,F,G)
E. (A,B,G)


32. Two kinds of chemical material are stored in six buckets(each bucket has only one kind of
chemical). The volumes of these buckets are: 8L, 13L, 15L, 17L, 19L and 31L. It is also known
that the price of one chemical is twice that of the other. A man has purchased five of the buckets,
and found that he spent the same amount money on each kind of chemical. Which bucket was left
unsold?

A. 8L

B. 13L

C. 15L

D. 17L

E. 19L
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值