c语言题库判断河南工业大学 河工大 c语言期末考试题库C language question文档格式.docx
《c语言题库判断河南工业大学 河工大 c语言期末考试题库C language question文档格式.docx》由会员分享,可在线阅读,更多相关《c语言题库判断河南工业大学 河工大 c语言期末考试题库C language question文档格式.docx(11页珍藏版)》请在冰豆网上搜索。
day,sum,and_pint
Ifcharcisdefined,thenc="
C"
"
;
TheClanguagecanuseasymbolicnametorepresentaconstant
Thefollowingproceduressegmentfloatx=3.6;
inti;
i=(int)x;
thenx=3,i=3
IntheClanguage,characterdatacanbearithmeticoperationswithintegerdata
Theaccuracycanbespecifiedwhenusingscanftoenterdata
InC(+,-)operatorcanonlybeusedforvariable
Thefloata=b=c=1.0iscorrectintheClanguage
Inputchar(c),Ccanbeanescapecharacter
~~~4
Theifstatement,whetherwrittenonafewlines,isawholeandbelongstothesamestatement.
Theentireifstatementcanbewrittenonmultiplelinesorwrittenonasingleline.
Intheifstatement,ifmusthaveelse.
Intheifstatement,elsemusthaveif.
Theelseclausecannotbeusedaloneasastatement,andmustbepairedwithif.
IntheClanguagecompilingsystem,whentheresultoflogicaloperationsisexpressed,thevalue"
1"
standsfor"
truth"
and"
0"
means"
false"
.
Arithmeticoperatorshaveprecedenceoverrelationaloperators.
Logicisnotthehighestpriorityinlogicaloperators.
Theswitchstatementisamultibranchselectionstatement.
Injudgingwhetheraquantityistrue,0represents"
true"
~~~5
IntheClanguage,3statementsthatimplementtheloopstructurearetheforstatement,thewhilestatement,andtheDO-WHILEstatement.
For((.))andwhile
(1)areinfiniteloops.
InC,thewhilestatementsthatimplementloopstructuresareexactlyequivalenttotheDO-WHILEstatements.
Theexecutionstatementfor(i=1;
i++<
4;
);
thevalueofthelattervariableIis4
Theforstatementcanonlybeusedincaseswherethenumberofcycleshasbeendetermined.
Theexistingdefinitionofintk=1;
executesthestatementwhile(++k<
4);
then,thevalueofKis4
~y.
#include<
stdio.h>
int(main)programj=10,i=0{int,k=2,s=0;
for(;
){i+=k;
if(i>
j){printf(%d,s);
break;
}s+=i;
}},judgei>
jcarriedout6.
Ints=36;
while(s)--s;
constitutesadeadloop.
Programsegmentint=0;
while(t=1){printf("
%d\n"
"
t"
}atruntime,theprintfstatementexecutes0times.
Program#include,<
int,main(),{int,x=23;
.Do{printf("
%d"
x--"
"
while"
("
X"
}theoutputoftheruntimeis23
~~~6
Whendefininganarray,anarraysubscriptcanberepresentedbyavariable
Whenreferencingelementsinanarray,thearraysubscriptcanberepresentedbyavariable
Inta[8];
definesanintegerarray;
thelastelementinthearrayisa[8]
Inta[6];
thefirstelementinthearrayisa[1]
Inta[2][3];
definesanarrayinwhichthereare6elementsinthearray
Supposethats[10]isanarrayofcharacters,byscanf("
s"
youcanenterastringtothearray
Inta[6]={0};
definesanarraya,andtheinitialvalueofeachelementinthearrayis0
Int,a[2][3]={{1},{2},{3}};
thecorrectmethodofinitialvaluesforanarray
Comparethesizeoftwostrings,andyoucanusethestrcpyfunction
Toconnecttwostrings,youcanusethestrcatfunction
Totestthelengthofastring,youcanusethestrlenfunction
~~~7
Ifthedefinitionofthecallfunctionappearsbeforethemainfunction,youdonothavetodeclareit.
TheClanguagecannotdefinefunctionsnested,norcannestedfunctionsbecalled.Thatistosay,nofunctioncanbecalledintheprocessofinvokingafunction
Thevariablesdefinedintheprimaryfunctionarealsovalidonlyintheprimaryfunction,notintheentirefileorprogrambecausetheyaredefinedinthemainfunction.Themainfunctioncannotusevariablesdefinedinotherfunctions.
Variablesindifferentfunctionscanusethesamename.Theyrepresentdifferentobjectsanddonotinterferewitheachother.
Withinafunction,variablescanbedefinedincompoundstatements,whicharevalidonlyinthecompoundstatement,whichisalsocalledasubprogramorablockofprograms"
Thevariablesdefinedinafunctionareexternalvariables,andvariablesdefinedoutsidethefunctionarecalledlocalvariables,andtheexternalvariablesareglobalvariables(alsoknownaswholevariables).
Localvariablescanbesharedbyotherfunctionsinthisdocument.Itsrangeofvaliditystartsfromthelocationofthedefinedvariabletotheendofthesourcefile.
Itcanbedividedintostaticstoragemodeanddynamicstoragemodefromthepointofviewoftheexistenceofvariablevalue.
Theso-calleddynamicstoragemeanswhentheprogramisrunning,thesystemallocatesafixedstoragespace.
Staticstorageisthewaytodynamicallyallocatestoragespaceasneededduringprogramexecution.
InC,ifapointervariableisusedtocallanargument,thepointervariableisdetermined,pointingtoadefinedcell.
IntheClanguage,thecallofafunctioncanonlygetareturnvalue,andthepointercanbeusedasafunctionparametertoobtainmultiplevalues.
InClanguage,inputandoutputstatementsareusedtoinputandoutputdata.
Whenusingtheputcharfunction,youmustincludetheheaderfilestdio.hbefore.
Usingtheputcharfunction,youcanoutputastringtotheterminal.
Usingtheprintffunction,youcanoutputbyacertainnumberofdigits.
Intheprintffunction,both%cand%scanoutputstrings.
Whenyouenterdataintoadefinedvariablewiththescanffunction,youmustadd&
Whendataisenteredintoadefinedvariableusingthescanffunction,thedatainputendswhenanillegalinputisentered.
Theuseofinputandoutputfunctions,putchar(getchar()),statementsarewrong(correct).
~~~8
Thepointertothearrayelementistheaddressoftheindexgroupelement.
TheprogramforexchangingtwopointervariablesP1andP2istemp=*p1;
*p1=*p2;
*p2=temp;
Printf("
a[i]"
)playsthesameroleasprintf("
*"
(a+i)),andtheformerisefficient.
Thearraynameoftheparameterisnotanationaladdress,butishandledbypointervariables.
Thepointertothefunctionthatdefinestheformatisint*p(int,int);
Theprogramsegmentsint,*p,a=2;
p=&
a;
printf("
*(p++));
theoutputis2
InC99,youcandefinepointervariablesofthebasetypeofvoid,whichcanpointtoanytypeofvariable.
TheprogramsegmentthatpointsPtothestring"
China"
ischar*p;
p="
Programsegmentsareint,a,m=4,n=6,*p1=&
m,*p2=&
n,a=(*p1)/(*p2)+5;
afterexecution,thevalueofais5
Voidf(int*n){while((*n)-(printf);
++(*n));
}(main){inta=1;
f(&
a);
}nooutput
~~~9
TheClanguageallowsuserstobuildtheirowncompositedatastructurescomposedofdifferenttypesofdata,calledstructures.
Thenameofthestructtypeisthenameofthestruct.
Whendefiningastruct,thetypeofamembermustbespecified,eitherasasimpledatatypeorasaconstructeddatatype.
Iftheprogramcontainsthestructtype,thenameofthestructmembercannotbethesameasthevariablenameintheprogram.
Membersofstructuralvariablescanperformvariousoperationsjustlikenormalvariables.
Eachelementofanarrayinanarrayofstructuresisofthesametype,andcanperforminputandoutputoperationsoneacharrayelementasawhole.
~~~10
Thefileidentifiercontainsthreeparts,
Filepath,filename,trunk,andfilesuffix.Thenamingruleofafilenamefollowsthenamingruleofanidentifier.Thesuffixisusedtorepresentthenatureofafile,consistingof3letters.
Accordingtotheorganizationofdata,datafilesaredividedintoASC||files(textfiles)andbinaryfiles(imagefiles),andASC||filessavestoragespacethanbinaryfiles.
Inthebufferfilesystem,eachusingthefilehasacorrespondingfileinformationinmemory,andthefileassociatedwiththefilepointertothefileinformationandita