2010年8月2日 星期一

華寶面試考題 from ptt

Assume architecture 32-bit
1.
sizeof(char)=?//1
sizeof(char*)=?//4
2.
unsigned short *a = (unsigned short*) 0x0008;
unsgined short *b = a + 1;//0x000a
b=?  
                                                                                
3.
int a=1;
int b = (a++) + (++a);//4
b=?
                                                                                
4.
union tt
{
        unsigned short a;
        unsigned short b[2];
        unsigned short c;
}A;
A.a=10;
A.c=20;
A.a=?//20
sizeof(tt)=?//4
                                                                                
5.
int a=3;
do{
        printf("%d\n", a-=2);
}while(!(--a));
console output?//1 -2
                                                                                
                                                                                
6.
int a=0x0c0c;
int b = (a>>4) | (a>>4);
b=?
                                                                                
7.
struct node
{
        int val;
        struct node *next;
}a,b,*p,*q;
p = &a;
q = &b;
請問下列哪個不能linked list
(a)a.next = q; (b) p->next = &b; (c) p.next = q; (d) (*p).next = q;
                                                                                
8.
char a = 45;
以下何者為零?
(a)a|a (b)a&a (c)a^a (d) a!=30  (c)
                                                                                
9.
void f(int a)
{
int b;
switch(a){
        case 1:
                b=1;
                break;
        case 2:
                b=2;
                break;
        case 3:
                b=3;
                //沒有break
        default:
                b=10;
}
return b;
}
printf("%d", f(3));
what is console output?

沒有留言:

張貼留言