ImageVerifierCode 换一换
格式:DOCX , 页数:12 ,大小:21.53KB ,
资源ID:8592205      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/8592205.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(C语言期末考试试题南昌航空大学.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

C语言期末考试试题南昌航空大学.docx

1、C语言期末考试试题南昌航空大学C语言期末考试试题 南昌航空大学一、单选题(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)C)E9 D)(3)有以下程序段char name20;int num;scanf(name=%s num=%d,name,&num);当执行上述程序段,并从键盘输入:name=Lili num=1001后,name的值为A)LiliB)name=LiliC)Lili num=D)name=Lili

2、 num=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(%dn,y);

3、程序运行后的输出结果是A)3 B)2 C)1 D) 0(7)设有如下函数定义int fun(int k) if (k1) return 0;else if(k=1) return 1;else return fun(k-1)+1;若执行调用语句:n=fun(3);,则函数fun总共被调用的次数是A)2 B)3 C)4 D)5(8)设有定义:struct char mark12;int num1;double num2; t1,t2;,若变量均已正确赋初值,则以下语句中错误的是A)t1=t2; B)=;C)=; D)=;(9)设fp已定义,执行语句fp=fopen(file,w);后,以下针对文

4、本文件file操作叙述的选项中正确的是A)写操作结束后可以从头开始读 B)只能写不能读C)可以在原有内容后追加写 D)可以随意读和写(10)以下叙述中错误的是A)C语言的可执行程序是由一系列机器指令构成的B)用C语言编写的源程序不能直接在计算机上运行C)通过编译得到的二进制目标程序需要连接才可以运行D)在没有安装C语言IDE的PC中不能运行C源程序生成的.exe文件(11)有以下程序#include void main() int x=011;printf(%dn,+x);程序运行后的输出结果是A)12 B)11 C)10 D)9(12)有以下程序#include void main() ch

5、ar s=012xy08s34f4w2;int i,n=0;for(i=0;si!=0;i+)if(si=0&si=9) n+;printf(%dn,n);程序运行后的输出结果是A)0 B)3 C)7 D)8(13)有以下程序#include void main() char b,c; int i;b=a; c=A;for(i=0;i6;i+) if(i%2) putchar(i+b);else putchar(i+c); printf(n);程序运行后的输出结果是A)ABCDEF B)AbCdEf C)aBcDeF D)abcdef(14)设有定义:double x10,*p=x;,以下能给

6、数组x下标为6的元素读入数据的正确语句是A)scanf(%f,&x6); B)scanf(%lf,*(x+6);C)scanf(%lf,p+6); D)scanf(%lf,p6);(15)有以下程序段#include void main() while( getchar()!=n);以下叙述中正确的是A)此while语句将无限循环B)getchar()不可以出现在while语句的条件表达式中C)当执行此while语句时,只有按回车键程序才能继续执行D)当执行此while语句时,按任意键程序就能继续执行(16)若有定义语句:char s310,(*k)3,*p;,则以下赋值语句正确的是A)p=s

7、; B)p=k; C)p=s0; D)k=s;(17)有以下程序#include void fun(char *c) while(*c) if(*c=a&*c=z) *c=*c-(a-A);c+;void 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);get

8、s(b);printf(%sn %sn,a,b);程序运行时若输入:how are you I am fine则输出结果是A)how are you B)how are you C)how are you I am fine D)howare you I am fine(19)有以下程序#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

9、(20)有以下程序#include struct S int a,b;data2=10,100,20,200;void main() struct S p=data1;printf(%dn,+);程序运行后的输出结果是A)10 B)11 C)20 D)21二、读程序写结果(1) 阅读下列程序:#include void main()int a; a=(int)(double)(3/2)+(int)*2); printf(%dn,a);上述程序的输出结果是(2) 阅读下列程序:#include int main() int i; int branch; double bonus,bon1,bon

10、2,bon4,bon6,bon10; bon1=100000*; bon2=bon1+100000*; bon4=bon2+200000*; bon6=bon4+200000*; bon10=bon6+400000*; scanf(%d,&i); branch=i/100000; if (branch10) branch=10; switch(branch) case 0:bonus=i*;break; case 1:bonus=bon1+(i-100000)*;break; case 2: case 3: bonus=bon2+(i-200000)*;break; case 4: case

11、5: bonus=bon4+(i-400000)*;break; case 6: case 7: case 8: case 9: bonus=bon6+(i-600000)*;break; case 10: bonus=bon10+(i-1000000)*; printf(奖金是 %n,bonus); return 0; 输入“234000”,上述程序的输出结果是(3)阅读下列程序:#include #include int main()double x1,x0,f,f1; x1=; do x0=x1; f=(2*x0-4)*x0+3)*x0-6; f1=(6*x0-8)*x0+3; x1=x

12、0-f/f1; while(fabs(x1-x0)=1e-5); printf(The root of equation is %n,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,&number); end=a9; if (numberend) a10=number; else for (i=0;inumber) temp1=ai; ai=number; for (j=i+1;j

13、11;j+) temp2=aj; aj=temp1; temp1=temp2; break; for (i=0;i11;i+) printf(%5d,ai); printf(n); return 0; 输入“50”,上述程序的输出结果是(5) 阅读下列程序:#include struct student int num; char name20; float score; ; int main() struct student stu3=10101,Zhang,78,10103,Wang,10106,Li,86; struct student temp; const int n=3; int

14、i,j,k; for(i=0;in-1;i+) k=i; for(j=i+1;jstuk.score) k=j; temp=stuk;stuk=stui;stui=temp; for(i=0;in;i+) printf(%6d %8s %n,stui.num,stui.name,stui.score); printf(n); return 0;上述程序的输出结果是(6) 阅读下列程序:#include int main()void copy_string(char *from, char *to); char *a=a teacher.; char b=a student.; char *p=

15、b; printf(string a=%snstring b=%sn,a,b); printf(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) for(;*from!=0;from+,to+) *to=*from; *to=0; 上述程序的输出结果是三、改写程序1.输出结果如图A所示,修改程序,要求(1)不输出第一行的空行;(2)“3”这行输出空行,如图B所示。 #inclu

16、de int main() int i,j,n=0; for (i=1;i=4;i+) for (j=1;j=5;j+,n+) if(n%5=0)printf(n); printf(%dt,i*j); printf(n); return 0; 图A 图B2.将求分段函数值的功能改写为自定义子函数,在主函数中通过键盘输入数据,调用子函数求函数值并输出。#include int main() int x,y; printf(输入x:); scanf(%d,&x); if(x1) /* x1 */ y=x; printf(x=%3d, y=x=%dn ,x,y); else if(x10) /* 1

17、=x=10 */ y=3*x-11; printf(x=%d, y=3*x-11=%dn,x,y); return 0;3.将实参和形参改写为指针方式。#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:%dn

18、space:%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 i=9) digit+; else if (stri=32) space+; else others+;4.第3题中不用全局变量,子函数用数组方式实现。5.将程序用while语句实现#include int main()double s=0,t=1; int n; for (n=1;n=20;n+) t=t*n; s=s+t; printf(1!+2!+.+20!=%n,s); return 0;

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1