嵌入式面试题
Linux笔试题 面试真题! 来源 : 未知     2016-09-22

一、选择题

1、有以下程序

float f1(float n)

{

return n*n;

}

float f2(float n)

{

return 2*n;

}

main()

{

float (*p1)(float),(*p2)(float),(*t)(float),y1,y2;

p1 = f1;

p2 = f2;

y1 = p2(p1(2.0));

t = p1;

p1 = p2;

p2 = t;

y2 = p2(p1(2.0));

printf("%3.0f,%3.0f\n",y1,y2);

}

程序运行结果是()

A、8,16 B、8,8 C、16,16 D、4,8

2、有以下程序

int a = 2;

int f(int n)

{

static int a = 3;

int t = 0;

if(n%2)

{

static int a = 4;

t+=a++;

}

else

{

static int a = 5;

t+=a++;

}

return t+a++;

}

main()

{

int s = a,i;

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

{

s+=f(i);

}

printf("%d\n",s);

}

程序运行结果是()

A、26 B、28 C、29 D、24

3、有以下程序

#include

struct STU

{

int num;

float totalscore;

};

void f(struct STU p)

{

struct STU s[2] = {{20044,550},{20045,537}};

p.num = s[1].num;

p.totalscore = s[1].totalscore;

}

main()

{

struct STU s[2] = {{20041,703},{20042,580}};

f(s[0]);

printf("%d %3.0f\n",s[0].num,s[0].totalscore);

}

程序运行结果是()

A、20045,537 B、20044,550 C、20042,580 D、20041,703

4、有以下程序

#include

struct STU

{

char name[10];

int num;

};

void f(char *name,int num)

{

struct STU s[2] = {{"sundan",20044},{"penghua",20045}};

num = s[0].num;

strcpy(name,s[0].name);

}

main()

{

struct STU s[2] = {{"yangsan",20041},{"lisiguo",20042}},*p;

p = &s[1];

f(p->name,p->num);

printf("%s %d\n",p->name,p->num);

}

程序运行结果是()

A、sundan 20042 B、sundan 20044 C、lisiguo 20042 D、yangsan 20041

5、有以下程序

#include

struct STU

{

char name[10];

int num;

float totalscore;

};

void f(struct STU *p)

{

struct STU s[2] = {{"sundan",20044,550},{"penghua",20045,537}},*q = s;

++p;

++q;

*p = *q;

}

main()

{

struct STU s[2] = {{"yangsan",20041,703},{"lisiguo",20042,580}};

f(s);

printf("%s %d %3.0f\n",s[1].name,s[1].num,s[1].totalscore);

}

程序运行结果是()

A、sundan 20042 550 B、sundan 20044 537 C、lisiguo 20042 580 D、yangsan 20041 703

6、以下程序的功能是进行位运算

main()

{

usigned char a,b;

a = 7^3;

b = -4&3;

printf("%d %d\n",a,b);

}

程序运行结果是()

A、4 3 B、7 3 C、7 0 D、4 0

7、有以下程序

#include

main()

{

FILE *fp;

int i,k,n;

fp = fopen("data dat","w+");

for(i = 1;i < 6;i++)

{

fprintf(fp,"%d",i);

if(i%3 == 0)

{

fprintf(fp,"\n");

}

}

rewind(fp);

fscanf(fp,"%d %d",&k,&n);

printf("%d %d\n",k,n);

fclose(fp);

}

程序运行结果是()

A、0 0 B、125 45 C、1 4 D、1 2

二、填空题

1、写出下面代码的输出内容

#include

main()

{

int a,b,c,d;

a = 10;

b = a++;

c = ++a;

d = 10*a++;

printf("b,c,d:%d %d %d",b,c,d);

return 0;

}

b = ___, c = ___, d = ___

2、在windows下,写出运行结果

char str[] = "Hello";

char *p = str;

int n = 10;

sizeof(str) = ___

sizeof(p) = ___

sizeof(n) = ___

void func(char str[100])

{

void *p = malloc(60);

}

sizeof(str) = ___

sizeof(p) = ___

3、在windows下,写出运行结果

void GetMemory(char *p)

{

p = (char *)malloc(100);

}

void Test(void)

{

char *str = NULL;

GetMemory(str);

strcpy(str,"hello world");

printf(str);

}

运行Test函数的结果_____

4、在windows下,写出运行结果

struct info

{

char name[6];

char sex[2];

char age[6];

};

struct info sdo;

strcpy(sdo.name,"陈冠希");

strcpy(sdo.name,"男");

strcpy(sdo.name,"26");

printf("name = %s",sdo.name);

输出结果是_____

5、在windows下,写出运行结果

int var = 300;

char i;

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

{

printf("%d",i+var);

}

printf("%d",var+100);

后一个输出是____

6、在windows下,写出运行结果

int arr[] = {6,7,8,9};

int *ptr = arr;

*(ptr++)+=123;

printf("%d,%d",*ptr,*(++ptr));

输出结果是____

7、以下程序的功能是进行位运算

main()

{

unsigned char a,b;

a = 7^3;

b = -4&3;

printf("%d%d\n",a,b);

}

程序运行结果是____,____

扫码申领本地嵌入式教学实录全套视频及配套源码

上一篇:嵌入式公司笔试题 面试真题

下一篇:嵌入式公司C++笔试题(真题)

400-611-6270

Copyright © 2004-2024 华清远见教育科技集团 版权所有
京ICP备16055225号-5京公海网安备11010802025203号