嵌入式面试问题及解答英文教学提纲.docx

上传人:b****6 文档编号:15505259 上传时间:2023-07-05 格式:DOCX 页数:16 大小:20.20KB
下载 相关 举报
嵌入式面试问题及解答英文教学提纲.docx_第1页
第1页 / 共16页
嵌入式面试问题及解答英文教学提纲.docx_第2页
第2页 / 共16页
嵌入式面试问题及解答英文教学提纲.docx_第3页
第3页 / 共16页
嵌入式面试问题及解答英文教学提纲.docx_第4页
第4页 / 共16页
嵌入式面试问题及解答英文教学提纲.docx_第5页
第5页 / 共16页
嵌入式面试问题及解答英文教学提纲.docx_第6页
第6页 / 共16页
嵌入式面试问题及解答英文教学提纲.docx_第7页
第7页 / 共16页
嵌入式面试问题及解答英文教学提纲.docx_第8页
第8页 / 共16页
嵌入式面试问题及解答英文教学提纲.docx_第9页
第9页 / 共16页
嵌入式面试问题及解答英文教学提纲.docx_第10页
第10页 / 共16页
嵌入式面试问题及解答英文教学提纲.docx_第11页
第11页 / 共16页
嵌入式面试问题及解答英文教学提纲.docx_第12页
第12页 / 共16页
嵌入式面试问题及解答英文教学提纲.docx_第13页
第13页 / 共16页
嵌入式面试问题及解答英文教学提纲.docx_第14页
第14页 / 共16页
嵌入式面试问题及解答英文教学提纲.docx_第15页
第15页 / 共16页
嵌入式面试问题及解答英文教学提纲.docx_第16页
第16页 / 共16页
亲,该文档总共16页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

嵌入式面试问题及解答英文教学提纲.docx

《嵌入式面试问题及解答英文教学提纲.docx》由会员分享,可在线阅读,更多相关《嵌入式面试问题及解答英文教学提纲.docx(16页珍藏版)》请在冰点文库上搜索。

嵌入式面试问题及解答英文教学提纲.docx

嵌入式面试问题及解答英文教学提纲

 

嵌入式面试问题及解答(英文)

Basiccquestion.

1.

Question:

whereinmemorythevariablesarestored?

Localvariables,globalvariables,static.

Answer

LocalvariablessitinStack.

GlobalandstaticgotoDatasegment.

DynamicmemorycomesfromHeap.

2.

Question

canyouexplianthemeaningforthefollwoingprogram

char*c1,*c2,*c3,*c4,*c5;

charanalysis[8]={'a','n','a','l','y','s','i','s'};

intmain()

{

c5=c4=analysis;

++c4;

c3=&analysis[6];

c2=c5+2;

c1=&analysis[7]-3;

printf("%c\t%c\t%c\t%c\t%c",*c1,*c2,*c3,*c4,*c5);

return0;

}

Answer

c1,c2,c3,c4andc5arepointers(whichcanholdaddresses).

analysisisanarrayvariablewhichisholdingthestring"analysis".

>c5=c4=analysis;

Thestartingaddressofthearrayisgiventoc5andc4.Hencetheypointtofirstcharacter'a'inthearray.

>++c4;

c4isincrementedby1.Hencepointsto'n'inthearray.

>c3=&analysis[6];

c3isgiventheaddressof7thcharacter(countfrom0)ofthearray.Hencec3pointstocharacter'i'.

>c2=c5+2;

c5pointstofirstcharacter.plus2means,c2pointsto3rdcharacter'a'(second'a'inthestring).

>c1=&analysis[7]-3;

c1pointsto3rdcharacterfromtheend(notcountingthelastcharacter).

c1holdstheaddress.*c1meansthedatastroredatc1.Sincec1pointsto3rdcharacterfromtheend(thatis5thcharacter-countstartsfrom0),*choldscharacter'y'.

Hence*c1willprint'y'onthescreen.

Similarlyforotherpointervariables*c2,*c3,*c4and*c5

3.

Question:

a=5b=10c=7

(a>c)?

a:

((b>c)?

b:

c)

Answer:

10

4

Question:

HowdoyoudeclareanarrayofNpointerstofunctionsreturning

pointerstofunctionsreturningpointerstocharacters?

A.char*(*(*a[N])())();

B.Buildthedeclarationupincrementally,usingtypedefs:

C.Usethecdeclprogram,whichturnsEnglishintoCandvice

versa:

D.Alloftheabove.

Answer:

D

5

Question:

voidmain()

{

intcount=10,*temp,sum=0;

temp=&count;

*temp=20;

temp=∑

*temp=count;

printf("%d%d%d",count,*temp,sum);

}

Answer:

20;20;20;

6

Question:

voidmain()

{

inti=7;

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

}

Answer:

49.

Note:

Don’tchangeavariabletwiceinoneexpression.

7

Question:

Thenumberofsyntaxerrorsintheprogram?

intf()

voidmain()

{

f

(1);

f(1,2);

f(1,2,3);

}

f(inti,intj,intk)

{

printf("%d%d%d",i,j,k);

}

Answer:

None.

8

Question:

voidmain()

{

floatj;

j=1000*1000;

printf("%f",j);

}

A.1000000

B.Overflow

C.Error

D.Noneoftheabove

Answer:

D

9

Question:

Givetheoutputoftheprogram

voidmain()

{

unsignedi=1;/*unsignedchark=-1=>k=255;*/

signedj=-1;/*chark=-1=>k=65535*/

/*unsignedorsignedintk=-1=>k=65535*/

if(i

printf("less");

else

if(i>j)

printf("greater");

else

if(i==j)

printf("equal");

}

Answer:

less

10

Givetheoutputoftheprogram

voidmain()

{

char*s="12345sn";

printf("%d",sizeof(s));

}

Answer:

4

11

Question:

Givetheoutputoftheprogram

voidmain()

{

inti;

for(i=1;i<4,i++)

switch(i)

case1:

printf("%d",i);break;

{

case2:

printf("%d",i);break;

case3:

printf("%d",i);break;

}

switch(i)case4:

printf("%d",i);

}

Answer:

1,2,3,4

12.

Question:

Howtopasstwoargumentstoafunctionpromptedtobyfunctionpointer

A.g->(1,2)

B.*g(1,2)

C.(*g)(1,2)

D.g(1,2)

Answer:

C

13

Question:

Canyouhaveconstantvolatilevariable?

Answer:

YES.Wecanhaveaconstvolatilevariable.

avolatilevariableisavariablewhichcanbechangedbytheextrenalevents(likeaninterrputtimerswillincrementthevoltilevarible.Ifyoudontwantyouvolatilevaribaletobechangedthendeclarethemas“constvolatile”.

14.

Question:

studythecode:

#include

voidmain()

{

constinta=100;

int*p;

p=&a;

(*p)++;

printf("a=%d\n(*p)=%d\n",a,*p);

}

Whatisprinted?

A)100,101B)100,100C)101,101D)Noneoftheabove

AnswerC

EmbeddedC

1.Usingthe#definestatement,howwouldyoudeclareamanifestconstantthatreturnsthenumberofsecondsinayear?

Disregardleapyearsinyouranswer.

Answer

#defineSECONDS_PER_YEAR(60*60*24*365)UL

I'mlookingforseveralthingshere:

Basicknowledgeofthe#definesyntax(forexample,nosemi-colonattheend,theneedtoparenthesize,andsoon)

Anunderstandingthatthepre-processorwillevaluateconstantexpressionsforyou.Thus,itisclearer,andpenalty-free,tospellouthowyouarecalculatingthenumberofsecondsinayear,ratherthanactuallydoingthecalculationyourself

Arealizationthattheexpressionwilloverflowanintegerargumentona16-bitmachine-hencetheneedfortheL,tellingthecompilertotreatthevariableasaLong

Asabonus,ifyoumodifiedtheexpressionwithaUL(indicatingunsignedlong),thenyouareofftoagreatstart.Andremember,firstimpressionscount!

2.Writethe"standard"MINmacro-thatis,amacrothattakestwoargumentsandreturnsthesmallerofthetwoarguments.

Answer:

#defineMIN(A,B)((A)<=(B)?

(A):

(B))

Thepurposeofthisquestionistotestthefollowing:

Basicknowledgeofthe#definedirectiveasusedinmacros.ThisisimportantbecauseuntiltheinlineoperatorbecomespartofstandardC,macrosaretheonlyportablewayofgeneratinginlinecode.Inlinecodeisoftennecessaryinembeddedsystemsinordertoachievetherequiredperformancelevel

Knowledgeoftheternaryconditionaloperator.ThisoperatorexistsinCbecauseitallowsthecompilertoproducemoreoptimalcodethananif-then-elsesequence.Giventhatperformanceisnormallyanissueinembeddedsystems,knowledgeanduseofthisconstructisimportant

Understandingoftheneedtoverycarefullyparenthesizeargumentstomacros

Ialsousethisquestiontostartadiscussiononthesideeffectsofmacros,forexample,whathappenswhenyouwritecodesuchas:

least=MIN(*p++,b);

3.Infiniteloopsoftenariseinembeddedsystems.HowdoesyoucodeaninfiniteloopinC?

Thereareseveralsolutionstothisquestion.Mypreferredsolutionis:

Answer:

while

(1)

{

?

}

5.Usingthevariablea,givedefinitionsforthefollowing:

a)Aninteger

b)Apointertoaninteger

c)Apointertoapointertoaninteger

d)Anarrayof10integers

e)Anarrayof10pointerstointegers

f)Apointertoanarrayof10integers

g)Apointertoafunctionthattakesanintegerasanargumentandreturnsaninteger

h)Anarrayoftenpointerstofunctionsthattakeanintegerargumentandreturnaninteger

Answers:

a)inta;//Aninteger

b)int*a;//Apointertoaninteger

c)int**a;//Apointertoapointertoaninteger

d)inta[10];//Anarrayof10integers

e)int*a[10];//Anarrayof10pointerstointegers

f)int(*a)[10];//Apointertoanarrayof10integers

g)int(*a)(int);//Apointertoafunctionathattakesanintegerargumentandreturnsaninteger

h)int(*a[10])(int);//Anarrayof10pointerstofunctionsthattakeanintegerargumentandreturnaninteger

Peopleoftenclaimthatacoupleofthesearethesortsofthingthatonelooksupintextbooks-andIagree.Whilewritingthisarticle,Iconsultedtextbookstoensurethesyntaxwascorrect.However,Iexpecttobeaskedthisquestion(orsomethingclosetoit)whenI'mbeinginterviewed.Consequently,ImakesureIknowtheanswers,atleastforthefewhoursoftheinterview.Candidateswhodon'tknowalltheanswers(oratleastmostofthem)aresimplyunpreparedfortheinterview.Iftheycan'tbepreparedfortheinterview,whatwilltheybepreparedfor?

6.Whataretheusesofthekeywordstatic?

Answer:

StatichasthreedistinctusesinC:

Avariabledeclaredstaticwithinthebodyofafunctionmaintainsitsvaluebetweenfunctioninvocations

Avariabledeclaredstaticwithinamodule,(butoutsidethebodyofafunction)isaccessiblebyallfunctionswithinthatmodule.Itisnotaccessiblebyfunctionswithinanyothermodule.Thatis,itisalocalizedglobal

Functionsdeclaredstaticwithinamodulemayonlybecalledbyotherfunctionswithinthatmodule.Thatis,thescopeofthefunctionislocalizedtothemodulewithinwhichitisdeclared

Mostcandidatesgetthefirstpartcorrect.Areasonablenumbergetthesecondpartcorrect,whileapitifulnumberunderstandthethirdanswer.Thisisaseriousweaknessinacandidate,sinceheobviouslydoesn'tunderstandtheimportanceandbenefitsoflocalizingthescopeofbothdataandcode.

7.Whatdothefollowingdeclarationsmean?

constinta;

intconsta;

constint*a;

int*consta;

intconst*consta;

Answer

Thefirsttwomeanthesamething,namelyaisaconst(read-only)integer.Thethirdmeansaisapointertoaconstinteger(thatis,theintegerisn'tmodifiable,butthepointeris).Thefourthdeclaresatobeaconstpointertoaninteger(thatis,theintegerpointedtobyaismodifiable,butthepointerisnot).Thefinaldeclarationdeclaresatobeaconstpointertoaconstinteger(thatis,neithertheintegerpointedtobya,northepointeritselfmaybemodified).

8.Whatdoesthekeywordvolatilemean?

Givethreedifferentexamplesofitsuse.

Answer:

Avolatilevariableisonethatcanchangeunexpectedly.Consequently,thecompilercanmakenoassumptionsaboutthevalueofthevariable.Inparticular,theoptimizermustbecarefultoreloadthevariableeverytimeitisusedinsteadofholdingacopyinaregister.Examplesofvolatilevariablesare:

Hardwareregistersinperipherals(forexample,statusregisters)

Non-automaticvariablesreferencedwithinaninterruptserviceroutine

Variablessharedbymultipletasksinamulti-threadedapplication

9.

Canapointerb

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 外语学习 > 英语学习

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2