c语言期末考试试题___南昌航空大学

上传人:第*** 文档编号:32803395 上传时间:2018-02-12 格式:DOC 页数:8 大小:55.83KB
返回 下载 相关 举报
c语言期末考试试题___南昌航空大学_第1页
第1页 / 共8页
c语言期末考试试题___南昌航空大学_第2页
第2页 / 共8页
c语言期末考试试题___南昌航空大学_第3页
第3页 / 共8页
c语言期末考试试题___南昌航空大学_第4页
第4页 / 共8页
c语言期末考试试题___南昌航空大学_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《c语言期末考试试题___南昌航空大学》由会员分享,可在线阅读,更多相关《c语言期末考试试题___南昌航空大学(8页珍藏版)》请在金锄头文库上搜索。

1、1C 语言期末考试试题 南昌航空大学一、单选题(1) 若要定义一个具有 5 个元素的整型数组,以下错误的定义语句是A)int a5=0;B)int b=0,0,0,0,0;C)int c2+3;D)int i=5,di;(2)以下选项中可用作 C 程序合法实数的是A).1e0 B)3.0e0.2C)E9 D)9.12E(3)有以下程序段char name20;int num;scanf(name=%s num=%d,name,当执行上述程序段,并从键盘输入:name=Lili num=1001后,name 的值为A)LiliB)name=LiliC)Lili num=D)name=Lili n

2、um=1001(4)if 语句的基本形式是:if(表达式) 语句,以下关于“表达式”值的叙述中正确的是A)必须是逻辑值 B)必须是整数值C)必须是正数 D)可以是任意合法的数值(5)若 i 和 k 都是 int 类型变量,有以下 for 语句for(i=0,k=-1;k=1;k+) printf(*n);下面关于语句执行情况的叙述中正确的是A)循环体执行两次B)循环体执行一次C)循环体一次也不执行D)构成无限循环(6)有以下程序#include void main() int x=1,y=0;if(!x) y+;else if(x=0)if (x) y+=2;else y+=3;printf(

3、%dn,y);程序运行后的输出结果是A)3 B)2 C)1 D) 0(7)设有如下函数定义int fun(int k) if (kvoid main() int x=011;printf(%dn,+x);程序运行后的输出结果是A)12 B)11 C)10 D)9(12)有以下程序#include void main() char s=012xy08s34f4w2;int i,n=0;for(i=0;si!=0;i+)if(si=0printf(%dn,n);程序运行后的输出结果是A)0 B)3 C)7 D)8(13)有以下程序#include void main() char b,c; int

4、 i;b=a; c=A;for(i=0;ivoid main() while( getchar()!=n);以下叙述中正确的是A)此 while 语句将无限循环B)getchar()不可以出现在 while 语句的条件表达式中C)当执行此 while 语句时,只有按回车键程序才能继续执行D)当执行此 while 语句时,按任意键程序就能继续执行(16)若有定义语句:char s310,(*k)3,*p;,则以下赋值语句正确的是A)p=s; B)p=k; C)p=s0; D)k=s;(17)有以下程序#include void fun(char *c) while(*c) if(*c=ac+;v

5、oid main() char s81;gets(s); fun(s); puts(s):当执行程序时从键盘上输入 Hello Beijing,则程序的输出结果是A)hello beijing B)Hello Beijing C)HELLO BEIJING D)hELLO Beijing(18)有以下程序#include void main() char a30,b30;scanf(%s,a);gets(b);printf(%sn %sn,a,b);程序运行时若输入:how are you? I am fine则输出结果是A)how are you? B)how are you? C)how

6、are you? I am fine D)howare you? I am fine(19)有以下程序4#include int fun (int x,int y) if (x!=y) return (x+y)/2);else return (x);void main() int a=4,b=5,c=6;printf(%dn,fun(2*a,fun(b,c);程序运行后的输出结果是A)3 B)6 C)8 D)12(20)有以下程序#include struct S int a,b;data2=10,100,20,200;void main() struct S p=data1;printf(%

7、dn,+(p.a);程序运行后的输出结果是A)10 B)11 C)20 D)21二、读程序写结果(1) 阅读下列程序:#include void main()int a;a=(int)(double)(3/2)+0.5+(int)1.99*2);printf(%dn,a);上述程序的输出结果是(2) 阅读下列程序:#include int main() int i; int branch;double bonus,bon1,bon2,bon4,bon6,bon10;bon1=100000*0.1; bon2=bon1+100000*0.075; bon4=bon2+200000*0.05;bo

8、n6=bon4+200000*0.03; bon10=bon6+400000*0.015;scanf(%d,branch=i/100000;if (branch10) branch=10;switch(branch) case 0:bonus=i*0.1;break;case 1:bonus=bon1+(i-100000)*0.075;break;case 2:case 3: bonus=bon2+(i-200000)*0.05;break;5case 4:case 5: bonus=bon4+(i-400000)*0.03;break;case 6: case 7: case 8:case

9、9: bonus=bon6+(i-600000)*0.015;break;case 10: bonus=bon10+(i-1000000)*0.01;printf(奖金是 %10.2fn,bonus);return 0;输入“234000” ,上述程序的输出结果是(3)阅读下列程序:#include #include int main()double x1,x0,f,f1;x1=1.5;dox0=x1;f=(2*x0-4)*x0+3)*x0-6;f1=(6*x0-8)*x0+3;x1=x0-f/f1;while(fabs(x1-x0)=1e-5);printf(The root of equa

10、tion is %5.2fn,x1);return 0;上述程序的输出结果是(4)阅读下列程序:#include int main() int a11=1,4,6,9,13,16,19,28,40,100;int temp1,temp2,number,end,i,j;scanf(%d,end=a9;if (numberend)a10=number;elsefor (i=0;inumber)temp1=ai;ai=number;for (j=i+1;jstruct student int num; char name20; float score; ; int main()struct stud

11、ent stu3=10101,Zhang,78,10103,Wang,98.5,10106,Li,86; struct student temp; const int n=3;int i,j,k;for(i=0;istuk.score) k=j;temp=stuk;stuk=stui;stui=temp; for(i=0;iint main()void copy_string(char *from, char *to);char *a=a teacher.;char b=a student.;char *p=b; printf(string a=%snstring b=%sn,a,b); pr

12、intf(ncopy string a to string b:n);copy_string(a,b); printf(string a=%snstring b=%sn,a,b); return 0;void copy_string(char *from, char *to) 7 for(;*from!=0;from+,to+)*to=*from;*to=0; 上述程序的输出结果是三、改写程序1.输出结果如图 A 所示,修改程序,要求( 1)不输出第一行的空行;(2) “3”这行输出空行,如图 B 所示。 #include int main()int i,j,n=0;for (i=1;iint

13、 main() int x,y;printf(输入 x:);scanf(%d,if(x=10 */ y=3*x-11;printf(x=%d, y=3*x-11=%dn,x,y);return 0;3.将实参和形参改写为指针方式。8#include int letter,digit,space,others;int main()void count(char );char text80;printf(input string:n); gets(text);printf(string:); puts(text);letter=0; digit=0; space=0; others=0;count(text);printf(nletter:%dndigit:%dnspace:%dnothers:%dn,letter,digit,space,others);return 0;void count(char str)int i;for (i=0;stri!=0;i+)if (stri=a& stri=A & stri=0 & str iint main()double s=0,t=1;int n;for (n=1;n=20;n+) t=t*n; s=s+t; printf(1!+2!+.+20!=%22.15en,s);return 0;

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 建筑/环境 > 工程造价

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号