高级语言程序设计c试卷,期末试卷高级语言程序设计_(B卷)

本文提供了一份C语言程序设计的期末试卷详细解析,包括基本概念应用、程序编写及调试等部分,帮助读者理解C语言的关键知识点。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

《期末试卷高级语言程序设计_(B卷)》由会员分享,可在线阅读,更多相关《期末试卷高级语言程序设计_(B卷)(8页珍藏版)》请在人人文库网上搜索。

1、试卷编号: ( B)卷课程编号: 课程名称: 高级语言程序设计 考试形式: 闭卷 适用班级: 姓名: 学号: 班级: 学院: 专业: 考试日期: 题号一二三四五六七八九十总分累分人 签名题分404020100得分考生注意事项:1、本试卷共8页,请查看试卷中是否有缺页或破损。如有立即举手报告以便更换。2、考试结束后,考生不得将试卷、答题纸和草稿纸带出考场一、 Fundamental Concepts of C(40 Points). 得分评阅人1(3 Points)The following C program is compiled and runs successfully. Write t。

2、he output that this program produces.#include main( )int a;float b;a = 7.0/3.0;printf(“%d n”, a);a = 9 % 4;printf(“%d n”, a);b = 4 + 7.0 / 2;printf(“%.1f n”, b);第 8 页 共 8页2(4 Points)The following C program is compiled and runs successfully. Write the output that this program produces.#include main()。

3、int x = 4;int y = 4;if ( (x = y) )printf(“Bingo”);elseprintf(“No go”);3(6 points)Variables a, b, and c are integers where a = 3, b = 4 and c = 5 respectively. Do the following C expressions evaluate to true or false? You answers should be either true or false.a) a|b+c&b=c b) !(x=a)&(y=b)&0c) !(a+b)+。

4、c-1&b+c/24. (4 Points)The code fragment (below) has an error. Change one character to remove the error.int total15;int factor115;int factor215;int i;for (i = 0; i #define NRows 8main()int i, j;for (i = 1; i main( )int n;int mult = 1;n = 1;while (n main( )int k = 8printf(%dn, k+);printf(%dn, +k);9. (。

5、3points)Assume we have declared the two dimensional array A in the C language,int a34;Which one is incorrect to refer to the element of the array?a) a02*1b) a13c) a4-20d) a04二Application(40 Points)得分评阅人1 (4 Points)The program below compiles without errors and executes correctly. Write the output of 。

6、this program.#include void swap1(int a, int b) int tmp = a;a = b;b = tmp;void swap2(int a) int tmp = a0;a0 = a1;a1 = tmp;main()int a2;a0 = 0;a1 = 1;swap1( a0, a1 );printf(%d, %dn, a0, a1 );swap2( a );printf(%d, %dn, a0, a1 );_____________________________________________ _____________________________。

7、________________ 2. (3 Points)What will be printed to the screen if we execute the code?#include main() int k,i;k = 0;while(k= k)break;k+;3(8 Points)The program is to find a number in an array. Fill in the blank to complete the following program.int BinarySearch(int a,int n,int search) int mid,top,b。

8、ottom;top=0;bottom=n-1;while(______________) mid=(top+bottom)/2;if(amid=search)return(mid+1);else if(searchamid);______________;else _________________; return(_______);main() int a6=1,2,3,4,5,6,s=2,n;n=BinarySearch(a,6,s);if(n=-1) printf(no found);else printf(location=%d,n);4. (6 Points)The followin。

9、g program compiles and executes without errors. Write the output of this program. #include main( ) char w 10= “ABCD”, “EFGH”, “IJKL”, “MNOP” ; int k;for (k=0;kint foo(int x) x+;return x;int bar(int y) y-;return y;main() int x = 1;int y = 3;foo(x);bar(y);printf(%d %dn,x,y);y = foo(x);x = bar(y);print。

10、f(%d %dn,x,y);6. (8 points)To accomplish the following program in which calculates the average score of 10 students.float average(float array ,int n) int i;float aver,sum=0;for(i=0;___________;i+)sum+=________;aver=___________;return (aver);main() float score10,aver; int i;printf(ninput 10 scores:);。

11、for(i=0;i10;i+)scanf(%f,&scorei);aver=_________________;printf(naverage score is %5.2fn,aver);7.(3 points)The following C program is compiled and runs successfully. Write the output the following program produces.main()char line81;strncpy(line,”Artifical”,3);puts(line);strcpy(&line3,” and Science”);。

12、puts(line);strcat(line,” of C”);puts(line);三.Programming in C.(20 points)得分评阅人1. (6 Points)Write a complete function (including the header and the body) to return the maximum value found in an array. The function prototype is already given to you. The variable num is the number of elements in the ar。

13、ray. You may assume that num is at least one. Do not write the code for the main function. Also, dont write any comments.double findmax(double array, int num);2. (6 Points)Write a program to generate a list of the primes between 2 and 1000.3. Write a function (including the header and the body) to sort a list of an integer array. The function prototype is already given to you. The variable n is the number of elements in the array. Do not write the code for the main function. Also, dont write any comments.void SortIntegerArray( int a,int n。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值