期末试卷高级语言程序设计_(b卷)

期末试卷高级语言程序设计_(b卷)

ID:18149725

大小:102.00 KB

页数:8页

时间:2018-09-14

上传者:xinshengwencai
期末试卷高级语言程序设计_(b卷)_第1页
期末试卷高级语言程序设计_(b卷)_第2页
期末试卷高级语言程序设计_(b卷)_第3页
期末试卷高级语言程序设计_(b卷)_第4页
期末试卷高级语言程序设计_(b卷)_第5页
资源描述:

《期末试卷高级语言程序设计_(b卷)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

试卷编号:(B)卷课程编号:课程名称:高级语言程序设计考试形式:闭卷适用班级:姓名:学号:班级:学院:专业:考试日期:题号一二三四五六七八九十总分累分人签名题分404020100得分考生注意事项:1、本试卷共8页,请查看试卷中是否有缺页或破损。如有立即举手报告以便更换。2、考试结束后,考生不得将试卷、答题纸和草稿纸带出考场一、FundamentalConceptsofC(40Points).得分评阅人1.(3Points)ThefollowingCprogramiscompiledandrunssuccessfully. Writetheoutputthatthisprogramproduces. #includemain(){inta;floatb; a=7.0/3.0;printf(“%d ”,a); a=9%4;printf(“%d ”,a);b=4+7.0/2;printf(“%.1f ”,b);}第8页共8页 2.(4Points)ThefollowingCprogramiscompiledandrunssuccessfully. Writetheoutputthatthisprogramproduces. #includemain(){intx=4;inty=4;if((x<=y)&&(x>=y))      printf(“Bingo”);else      printf(“Nogo”);}3.(6points)Variablesa,b,andcareintegerswherea=3,b=4andc=5respectively.DothefollowingCexpressionsevaluatetotrueorfalse?Youanswersshouldbeeithertrueorfalse. a)a||b+c&&b==cb)!(x=a)&&(y=b)&&0c)!(a+b)+c-1&&b+c/24.(4Points)Thecodefragment(below)hasanerror.Changeonecharactertoremovetheerror. inttotal[15];intfactor1[15];intfactor2[15];inti; for(i=0;i<=15;i++)total[i]=factor1[i]+factor2[i]+factor2[i/2];5.(8Points)ThefollowingCprogramiscompiledandrunssuccessfully.Writetheoutputthefollowingprogramproduces.#include#defineNRows8main(){inti,j;for(i=1;i<=NRows;i++){for(j=0;j main(){intn;intmult=1; n=1;while(n<5){mult=mult*n;n++;} printf("Answeris%d ",mult);}8.  (2points)ThefollowingCprogramiscompiledandrunssuccessfully.Writetheoutputthefollowingprogramproduces. #includemain(){intk=8printf("%d ",k++);printf("%d ",++k); }9.(3points)AssumewehavedeclaredthetwodimensionalarrayAintheClanguage, inta[3][4];Whichoneisincorrecttorefertotheelementofthearray?a)a[0][2*1]b)a[1][3]c)a[4-2][0]d)a[0][4]第8页共8页 二.Application(40Points)得分评阅人1(4Points)Theprogrambelowcompileswithouterrorsandexecutescorrectly.Writetheoutputofthisprogram.#includevoidswap1(inta,intb){inttmp=a;a=b;b=tmp;}voidswap2(inta[]){inttmp=a[0];a[0]=a[1];a[1]=tmp;}main(){inta[2];a[0]=0;a[1]=1;swap1(a[0],a[1]);printf("%d,%d ",a[0],a[1]);swap2(a);printf("%d,%d ",a[0],a[1]);}__________________________________________________________________________________________2.(3Points)Whatwillbeprintedtothescreenifweexecutethecode? #include main(){intk,i;k=0;while(k<2){for(i=0;;i=i+1){printf("Hello! ");if(i>=k)break;}k++;}}第8页共8页 3.(8Points)Theprogramistofindanumberinanarray.Fillintheblanktocompletethefollowingprogram.intBinarySearch(inta[],intn,intsearch){intmid,top,bottom;top=0;bottom=n-1;while(______________){mid=(top+bottom)/2;if(a[mid]==search)return(mid+1);elseif(search>a[mid]);______________;else_________________;}return(_______);}main(){inta[6]={1,2,3,4,5,6},s=2,n;n=BinarySearch(a,6,s);if(n==-1)printf("nofound");elseprintf("location=%d",n);}4.(6Points)Thefollowingprogramcompilesandexecuteswithouterrors.Writetheoutputofthisprogram.#includemain(){charw[][10]={“ABCD”,“EFGH”,“IJKL”,“MNOP”};intk;for(k=0;k<3;k++)printf(“%s ”,&w[k][k]);}第8页共8页 5.(8Points)Thefollowingprogramcompilesandexecuteswithouterrors.Writetheoutputofthisprogram.#includeintfoo(intx){x++;returnx;}intbar(inty){y--;returny;}main(){intx=1;inty=3;foo(x);bar(y);printf("%d%d ",x,y);y=foo(x);x=bar(y);printf("%d%d ",x,y);}6.(8points)Toaccomplishthefollowingprograminwhichcalculatestheaveragescoreof10students.floataverage(floatarray[],intn){inti;floataver,sum=0;for(i=0;___________;i++)sum+=________;aver=___________;return(aver);}main(){floatscore[10],aver;inti;printf(" input10scores:");for(i=0;i<10;i++)scanf("%f",&score[i]);aver=_________________;printf(" averagescoreis%5.2f ",aver);}第8页共8页 7.(3points)ThefollowingCprogramiscompiledandrunssuccessfully.Writetheoutputthefollowingprogramproduces.main(){charline[81];strncpy(line,”Artifical”,3);puts(line);strcpy(&line[3],”andScience”);puts(line);strcat(line,”ofC”);puts(line);}三.ProgramminginC.(20points)得分评阅人1.(6Points)Writeacompletefunction(includingtheheaderandthebody)toreturnthemaximumvaluefoundinanarray.Thefunctionprototypeisalreadygiventoyou.Thevariablenumisthenumberofelementsinthearray.Youmayassumethatnumisatleastone.Donotwritethecodeforthemainfunction.Also,don’twriteanycomments.doublefindmax(doublearray[],intnum);第8页共8页 2.(6Points)Writeaprogramtogeneratealistoftheprimesbetween2and1000.3.Writeafunction(includingtheheaderandthebody)tosortalistofanintegerarray.Thefunctionprototypeisalreadygiventoyou.Thevariablenisthenumberofelementsinthearray.Donotwritethecodeforthemainfunction.Also,don’twriteanycomments.voidSortIntegerArray(inta[],intn);第8页共8页

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。
关闭