应届大学生面试技巧嵌入式方面3
应届大学生面试技巧嵌入式方面(3)
作为一个即将毕业的大学生,在外地实习工作确实是一件很痛苦的事情,我们没有很强的技能(除过那些很BT的家伙),没有一定的社会阅历,甚至没有一点家庭背景.但是作为企业来说,他们在很大程度上也都是很了解应届大学生的,他们对我们的要求不是很高,除非有的公司是想刁难你,但是这样的事情是很少发生的,
我就我在北京的一些工作的经验和学习到的一些知识分享给大家,仅代表一家之言,不足之处请大家指正.
操作篇:发些代码给大家做做笔试参考.
1.下面的代码输出是什么,为什么?
void foo(void)
{ unsigned int a = 6;
int b = -20;
(a+b > 6) puts("> 6") : puts("<= 6");
}
int b = -20;
(a+b > 6) puts("> 6") : puts("<= 6");
}
2.评价下面的代码片断:
unsigned int zero = 0;
unsigned int compzero = 0xFFFF;
unsigned int compzero = 0xFFFF;
对于一个int型不是16位的处理器为说,上面的代码是不正确的。应编写如下:
unsigned int compzero = ~0;
3.求输出char *ptr;
if ((ptr = (char *)malloc(0)) == NULL)
puts("Got a null pointer");
else
if ((ptr = (char *)malloc(0)) == NULL)
puts("Got a null pointer");
else
puts("Got a valid pointer");
4.C语言同意一些令人震惊的结构,下面的结构是合法的吗,如果是它做些什么?
int a = 5, b = 7, c;
c = a+++b;
int a = 5, b = 7, c;
c = a+++b;
5.What will print out?
main
{ char *p1=“name”;
char *p2;
p2=(char*)malloc(20);
memset (p2, 0, 20);
while(*p2++ = *p1++);printf怎么加endl
printf(“%sn”,p2);
{ char *p1=“name”;
char *p2;
p2=(char*)malloc(20);
memset (p2, 0, 20);
while(*p2++ = *p1++);printf怎么加endl
printf(“%sn”,p2);
}
Answer:empty string.
What will be printed as the result of the operation below:
main
{ int x=20,y=35;
x=y++ + x++;
y= ++y + ++x;
printf(“%d%dn”,x,y);
}
{ int x=20,y=35;
x=y++ + x++;
y= ++y + ++x;
printf(“%d%dn”,x,y);
}
Answer : 5794
What will be printed as the result of the operation below:
main
{ int x=5;
printf(“%d,%d,%dn”,x,x<<2,x>>2);
{ int x=5;
printf(“%d,%d,%dn”,x,x<<2,x>>2);
}
Answer: 5,20,1
What will be printed as the result of the operation below:
#define swap(a,b) a=a+b;b=a-b;a=a-b;
void main
{ int x=5, y=10;
swap (x,y);
printf(“%d %dn”,x,y);
swap2(x,y);
printf(“%d %dn”,x,y);
}
void main
{ int x=5, y=10;
swap (x,y);
printf(“%d %dn”,x,y);
swap2(x,y);
printf(“%d %dn”,x,y);
}
int swap2(int a, int b)
{ int temp;
{ int temp;
temp=a;
b=a;
a=temp;
return 0;
b=a;
a=temp;
return 0;
}
Answer: 10, 5
10, 5
10, 5
What will be printed as the result of the operation below:
main
{ char *ptr = ” Cisco Systems”;
*ptr++; printf(“%sn”,ptr);
ptr++;
printf(“%sn”,ptr);
}
{ char *ptr = ” Cisco Systems”;
*ptr++; printf(“%sn”,ptr);
ptr++;
printf(“%sn”,ptr);
}
Answer:Cisco Systems
isco systems
isco systems
What will be printed as the result of the operation below:
main
{ char s1[]=“Cisco”;
char s2[]= “systems”;
printf(“%s”,s1);
} Answer: Cisco
{ char s1[]=“Cisco”;
char s2[]= “systems”;
printf(“%s”,s1);
} Answer: Cisco
What will be printed as the result of the operation below:
main
{ char *p1;
char *p2;
p1=(char *)malloc(25);
p2=(char *)malloc(25);
{ char *p1;
char *p2;
p1=(char *)malloc(25);
p2=(char *)malloc(25);
strcpy(p1,”Cisco”);
strcpy(p2,“systems”);
strcat(p1,p2);
strcpy(p2,“systems”);
strcat(p1,p2);
printf(“%s”,p1);
}
Answer: Ciscosystems
The following variable is available in file1.c, who can access it?:
static int average;
Answer: all the functions in the file1.c can access the variable.
WHat will be the result of the following code?
#define TRUE 0 // some code
while(TRUE)
{
{
// some code
}
Answer: This will not go into the loop as TRUE is defined as 0.
What will be printed as the result of the operation below:
int x;
int modifyvalue
{ return(x+=10);
} int changevalue(int x)
{ return(x+=1);
}
int modifyvalue
{ return(x+=10);
} int changevalue(int x)
{ return(x+=1);
}
void main
{ int x=10;
x++;
changevalue(x);
x++;
modifyvalue;
printf("First output:%dn",x);
{ int x=10;
x++;
changevalue(x);
x++;
modifyvalue;
printf("First output:%dn",x);
x++;
changevalue(x);
printf("Second output:%dn",x);
modifyvalue;
printf("Third output:%dn",x);
changevalue(x);
printf("Second output:%dn",x);
modifyvalue;
printf("Third output:%dn",x);
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论