You are on page 1of 9

10/25/2015

MemoryBasedProgrammingAMCATquestionsPART1|AMCATBLOG

AMCATBLOG
MEMORYBASEDAMCATQUESTIONS

MemoryBasedProgrammingAMCATquestions
PART1
March7,2014August26,2014
nehal001
COMPUTERSCIENCE,MEMORY
BASEDQUESTIONS,PROGRAMMING
AMCAT,CPROGRAMMING,MEMORYBASED
QUESTIONSAMCAT
ProgrammingquestionsarefromCaswellasC++,whileOOPSquestionsformanimportantpart
ofC++questions,youcanrefertotheminmyearlierpost
(https://amcatblog.wordpress.com/2014/03/07/memorybasedoopsamcatquestions/).Forthe
syllabustoComputerProgrammingSectionrefertomyearlierpost
(https://amcatblog.wordpress.com/2014/03/06/additionalmodulesyllabusforamcat/).
FUNCTIONSarequiteimportant,youwillfindalotofquestionsonit.Anotherthingwhichisof
vitalimportanceisPOINTERandPointerArithmetic.
Nowthequestions;
Que:Choosethecorrectanswer
Theforloopisequivalenttoawhileloopwhen
Option1:Thereisnoinitializationexpression
Option2:Thereisnoincrementexpression
Option3:AandBcombinedaretrue
Option4:Itisneverequivalent
Que:Choosethecorrectanswer
Assumingn>2,Whatvaluedoesthefollowingfunctioncomputeforoddn?
functionf(intn)
{
if(nequals1){return1}

https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcatquestions/

1/9

10/25/2015

MemoryBasedProgrammingAMCATquestionsPART1|AMCATBLOG

if(nequals2){returnf(n1)+n/2}
returnf(n2)+n;
}
Option1:1+2+3+4++n
Option2:1+3+5+7++n
Option3:n/2+(1+3+5+7++n)
Option4:1+(1+3+5+7++n)
Que:Choosethecorrectanswer
functiong(intn)
{
if(n>0)return1;
elsereturn1;
}
functionf(inta,intb)
{
if(a>b)returng(ba);
if(a<b)returng(ab);
return0;
}
Iff(a,b)iscalled,whatisreturned?
Option1:Always1
Option2:1ifa>b,1ifa<b,0otherwise
Option3:1ifa>b,1ifa<b,0otherwise
Option4:0ifaequalsb,1otherwise
Que:Choosethecorrectanswer
Ifyouwanttowriteafunctionthatswapsthevaluesoftwovariables,youmustpassthemby:
Option1:Valueonly
Option2:Referenceonly
Option3:EitherAorB
Option4:NeitherAnorB
Que:Choosethecorrectanswer
Whichoneofthefollowingisthelowestlevelformattowhichthecomputerconvertsahigher
languageprogrambefore
execution?
Option1:Englishcode
Option2:MachineCode
Option3:AssemblyLanguage
https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcatquestions/

2/9

10/25/2015

MemoryBasedProgrammingAMCATquestionsPART1|AMCATBLOG

Option4:SystemLanguage
Que:Choosethecorrectanswer
Geetikawritesapieceofcode,whereasetofeightlinesoccuraround10timesindifferentpartsof
theprogram(Code
A).ShepassesonthecodetoDeva.Devaputsthesetofeightlinesinafunctiondefinitionand
callsthematthe10
pointsintheprogram(CodeB).Whichcodewillrunfasterusinganinterpreter?
Option1:CodeA
Option2:CodeB
Option3:CodeAandCodeBwillrunwiththesamespeed
Option4:Noneofthese
Que:Choosethecorrectanswer
Afzalwritesapieceofcode,whereasetofthreelinesoccuraround10timesindifferentpartsof
theprogram.What
programmingconceptcanheusetoshortenhisprogramcodelength?
Option1:Useforloops
Option2:Usefunctions
Option3:Usearrays
Option4:Useclasses
Que:Choosethecorrectanswer
Considerthefollowingcode:
functionmodify(y,z)
{
y=y+1;
z=z+1;
returnyz
}
functioncalculate()
{
integera=5,b=10,c
c=modify(a,b);
printa
printspace
printc
}

Assumethataandbwerepassedbyvalue.Whatwillbetheoutputonexecutingfunction

https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcatquestions/

3/9

10/25/2015

MemoryBasedProgrammingAMCATquestionsPART1|AMCATBLOG

Assumethataandbwerepassedbyvalue.Whatwillbetheoutputonexecutingfunction
calculate()?
Option1:115
Option2:105
Option3:65
Option4:55
Que:Choosethecorrectanswer
Considerthefollowingfunction
functioncalculate(n)
{
if(nequals5)
return5
else
return(n+calculate(n5))
end
}
Shishircallsthefunctionbythestatement,calculate(20).Whatvaluewillthefunctionreturn?
Option1:50
Option2:200
Option3:35
Option4:20
Que:Choosethecorrectanswer
Saloniwritesthecodeforafunctionthattakesasinputn,anevenintegerandcalculatesthesum
offirstnevennatural
numbers.
functionsum(n)
{
if(nequals2)
return2
else
return(n+sum(n2))
end
}
Shethencallsthefunctionbythestatement,sum(30).Howmanytimeswillthefunctionsumbe
calledtocomputethis
sum.
Option1:1

https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcatquestions/

4/9

10/25/2015

MemoryBasedProgrammingAMCATquestionsPART1|AMCATBLOG

Option1:1
Option2:30
Option3:15
Option4:16
Que:Choosethecorrectanswer
Tanujwritesthecodeforafunctionthattakesasinputnandcalculatesthesumoffirstnnatural
numbers.
Functionsum(n)
{
if(??)
return1
else
return(n+sum(n1))
end
}
Fillin??inthecode.
Option1:nequals1
Option2:nequals2
Option3:n>=1
Option4:n>1
Que:Choosethecorrectanswer
Shrishtiwritesthecodeforafunctionthatcomputesthefactorialoftheinputtednumbern.
functionfactorial(n)
{
if(nequals1)
return1
else
MISSINGSTATEMENT
end
}
Fillinthemissingstatement.
Option1:returnfactorial(n1)
Option2:returnn*factorial(n)
Option3:returnn*(n1)
Option4:returnn*factorial(n1)
Que:Choosethecorrectanswer
Saumyawritesacodewhichhasafunctionwhichcallsitself.Whichprogrammingconceptis
Saumyausing?
https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcatquestions/

5/9

10/25/2015

MemoryBasedProgrammingAMCATquestionsPART1|AMCATBLOG

Option1:Thisisbadprogrammingpracticeandshouldnotbedone.
Option2:Recursion
Option3:DecisionMaking
Option4:Overloading
Que:Choosethecorrectanswer
CodeAhastoexecute4*n2+64programstatements,whileCodeBhastoexecute32*nprogram
statementsfora
problemofsizen.Thetimeforexecutingasingleprogramstatementissameforallstatements.
Rajeshwasgivena
problemwithacertainsizekandhedeliveredCodeA.Whatcouldbethepossiblevalueofk?
Option1:1000
Option2:5
Option3:10
Option4:3
Que:Choosethecorrectanswer
Pavithraisgiventwocodes,AandB,tosolveaproblem,whichhavecomplexity?(n3)and?(n3)
respectively.Her
clientwantstosolveaproblemofsizek,whichissufficientlylarge.Whichcodeshouldshe
delivertotheclientinthe
presentscenario?
Option1:CodeA
Option2:CodeB
Option3:Bothcodeshavethesameexecutiontime,sodeliverany.
Option4:Noneofthese
Que:Choosethecorrectanswer
Vibhuisgiventwocodes,AandB,tosolveaproblem,whichhavecomplexityO(n4)and?(n3)
respectively.Herclient
wantstosolveaproblemofsizek,whichissufficientlylarge.WhichcodewillGautamdeliverto
theclient,sothatthe
executionisfaster?
Option1:CodeA
Option2:CodeB
Option3:Vibhucannotdetermine
Option4:Bothcodeshavethesameexecutiontime,sodeliverany.

https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcatquestions/

6/9

10/25/2015

MemoryBasedProgrammingAMCATquestionsPART1|AMCATBLOG

About these ads (https://wordpress.com/about-these-ads/)

19thoughtsonMemory Based Programming


AMCAT questions PART1
1. Harikasays:
April22,2014at6:15am
Noanswersareprovidedhere
Reply(https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcat
questions/?replytocom=23#respond)
nehal001says:
April22,2014at8:19am
yes!ourreadersaresupposedtoanswerthem.ifyouneedhelpwithcertainquestion.
kindlymsgme
Reply(https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcat
questions/?replytocom=24#respond)
Harikasays:
April22,2014at8:22am
ineedalltheanswers
Nishantsays:
August24,2014at8:55am
Sirplzmailmeanswer
harikeshsays:
September26,2014at2:43pm
wheredoalltheleafnodeofaheaptreelie
1.leftsideoftree
2.oneleveloftree
https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcatquestions/

7/9

10/25/2015

MemoryBasedProgrammingAMCATquestionsPART1|AMCATBLOG

3.someleveloftree
4.twoadjecentleveloftree
siranswer?????
Ashoksays:
September18,2014at11:34am
siranswers
Reply(https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcat
questions/?replytocom=445#respond)
2. jyothirmaiesays:
August28,2014at4:21am
mailmeanswers
Reply(https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcat
questions/?replytocom=161#respond)
nehal001says:
August28,2014at4:28am
keepatabonmyfutureposts,uwillgettheanswershereitself!
Reply(https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcat
questions/?replytocom=162#respond)
Ashoksays:
October2,2014at7:42pm
sirplzprovidetheanswers
3. jyothirmaiesays:
September2,2014at10:01am
canuplprovideanswershereitselfpl
Reply(https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcat
questions/?replytocom=226#respond)
nehal001says:
September2,2014at4:51pm
iwill,canusolveatlstsomeofem.oratleasttry,shareurdoubts,thatwaywealllearn
Reply(https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcat
questions/?replytocom=231#respond)
Dilpreetsays:
November21,2014at11:07am
ihavetrieddquestionsbtemntabletoseeifmyanswersarerightornot.Idontwant
togivewronganswrsinppr.
4. Veerasays:
September12,2014at3:34pm
Answerplease
https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcatquestions/

8/9

10/25/2015

MemoryBasedProgrammingAMCATquestionsPART1|AMCATBLOG

Reply(https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcat
questions/?replytocom=376#respond)
5. Veerasays:
September13,2014at1:12pm
Doyouhaveanswersforthisornot?
Reply(https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcat
questions/?replytocom=386#respond)
6. phanikishoresays:
October1,2014at8:08am
sirpleaseprovideanswers
Reply(https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcat
questions/?replytocom=514#respond)
7. ShaikSumiyasays:
November21,2014at7:02pm
howtoanswerthosecomplexityquestions?
Icouldntunderstandthose..plzreplywithsolutionforoneofthosetypequestions.
Thankyou.
Reply(https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcat
questions/?replytocom=638#respond)
8. SUBODHKUMARsays:
January8,2015at8:11pm
Sirtheforloopisequivalenttowhileloop..
Answerofthisquestionis
Reply(https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcat
questions/?replytocom=734#respond)
9. balpreetkaursays:
July10,2015at9:33am
siranswertoallofthesequestionspleeease
Reply(https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcat
questions/?replytocom=873#respond)
10. Anshulasays:
August4,2015at2:09pm
answerisc@subodh
Reply(https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcat
questions/?replytocom=892#respond)

CreateafreewebsiteorblogatWordPress.com(https://wordpress.com/?ref=footer_website).
TheBigBrotherTheme(https://wordpress.com/themes/bigbrother/).
https://amcatblog.wordpress.com/2014/03/07/memorybasedprogrammingamcatquestions/

9/9