大一C语言课后习题答案
C语言程序设计教程课后习题答案

C语言程序设计教程课后习题答案第一章C语言程序设计概述-习题答案1算法的描述有哪些基本方法?答1、自然语言2、专用工具2C语言程序的基本结构是怎样的?举一个例子说明。
答1、C语言程序由函数构成;2、“/*”与“*/”之间的内容构成C语言程序的注释部分;3、用预处理命令#include、#define可以包含有关文件或预定义信息;4、大小写字母在C语言中是有区别的;5、除main()函数和标准库函数外,用户也可以自己编写函数,应用程序一般由多个函数组成,这些函数指定实际所需要做的工作。
3C语言有什么特点?答1、具有结构语言的特点,程序之间很容易实现段的共享;2、主要结构成分为函数,函数可以在程序中被定义完成独立的任务,独立地编译代码,以实现程序的模块化;3、运算符丰富,包含的范围很广;4、数据类型丰富;5、允许直接访问物理地址,即可直接对硬件进行损伤,实现汇编语言的大部分功能;6、限制不太严格,程序设计自由度大,这样使C语言能够减少对程序员的束缚;7、生成的目标代码质量,程序执行效率高,同时C语言编写的程序的可移植性好。
4★指出合法与不合法的标识符命名。
答AB12--√ leed_3-- a*b2--× 8stu--× D.K.Jon--× EF3_3--√ PAS--√ if--×XYZ43K2--√ AVE#XY--× _762--√ #_DT5--× C.D--×5说明下列Turbo C热键的功能。
答F2:源文件存盘 F10:调用主菜单 F4:程序运行到光标所在行(用于调试程序)Ctrl+F9:编译并链接成可执行文件 Alt+F5:将窗口切换到 DOS 下,查看程序运行结果。
6说明下列Turbo C方式下输入并运行下列程序,记录下运行结果。
①main(){printf("********************\n");printf(" welcome you \n");printf(" very good \n);printf("********************\n");}②main(){ int a,b,c,t;printf("please input three numbers;");scanf("%d,%d,%d",&a,&b,&c); /*教材S是错误的*/t=max(max(a,b),c);printf("max number is:%d\n",t);}int max(int x, int y){ int z;if(x>y)z=x;else z=y;return(z);}答运行结果:********************welcome youvery good********************运行结果:please input three numbers;3,1,4 /*左侧下划线内容为键盘输入*/max number is:47一个C程序是由若干个函数构成的,其中有且只能有一个___函数。
大一c语言习题练习及答案

第一章程序设计与C语言1.1 选择题考点:标识符的命名规则(1)只能由字母、数字、下划线构成(2)数字不能作为标识符的开头(3)关键字不能作为标识符选项A中的“-” ,选项B中“[”与“]”不满足(1);选项D中的int为关键字,不满足(3)1.下列正确的标识符是(C)。
A.-a1B.a[i]C.a2_iD.int t2.下列C语言用户标识符中合法的是(B)。
A)3ax B)x C)case D)-e2 E)union选项A中的标识符以数字开头不满足(2);选项C,E均为为关键字,不满足(3);选项D中的“-”不满足(1);3.下列四组选项中,正确的C语言标识符是(C )。
A)%x B)a+b C)a123 D)123选项A中的“%” ,选项B中“+”不满足(1);选项D中的标识符以数字开头不满足(2)4.下列四组字符串中都可以用作C语言程序中的标识符的是(A )。
A、print _3d db8 aBcB、I\am one_half start$it 3paiC、str_1 Cpp pow whileD、Pxq My->book line# His.age选项B中的“\”,”$” ,选项D中“>”,”#”,”.”,”-”不满足(1);选项C中的while为关键字,不满足(3)知识点:简单C语言程序的构成和格式5.在一个C程序中___B___。
A、main函数必须出现在所有函数之前B、main函数可以在任何地方出现C、main函数必须出现在所有函数之后D、main函数必须出现在固定位置6.以下说法中正确的是__D____。
A、#define和printf都是C语句B、#define是C语句,而printf不是C、printf是C语句,但#define不是D、#define和printf都不是C语句7.一个C程序的执行是从(A )。
A本程序的main函数开始,到main函数结束B本程序文件的第一个函数开始,到本程序文件的最后一个函数结束C本程序的main函数开始,到本程序文件的最后一个函数结束D本程序文件的第一个函数开始,到本程序main函数结束8.在C 语言中,每个语句必须以(D )结束。
大一c语言考试题库及详解答案

大一c语言考试题库及详解答案一、选择题1. 在C语言中,以下哪个选项是正确的整型常量?A. 0x123B. 0123C. 123.0D. 1.23e3答案:A2. 以下哪个关键字用于定义C语言中的函数?A. classB. functionC. defD. void答案:D3. 在C语言中,以下哪个选项不是合法的变量名?A. _myVarB. myVar_C. 2myVarD. myVar答案:C二、填空题1. C语言中,用于定义一个整型变量并赋值为10的语句是 int myInt = 10; 。
2. 若有定义 int a = 5;,则表达式 a++ 的结果是 5 ,a 的新值是 6 。
3. 在C语言中,字符串字面量以 " " 括起来。
三、简答题1. 请解释C语言中的指针是什么?指针是一种特殊的变量,它存储的是另一个变量的内存地址。
通过指针,程序可以间接访问和修改其他变量的值。
2. 描述C语言中数组和指针的关系。
在C语言中,数组名可以被看作指向数组首元素的指针。
因此,可以通过指针运算来访问数组中的元素。
四、编程题1. 编写一个C语言程序,计算并输出100以内所有奇数的和。
```c#include <stdio.h>int main() {int sum = 0;for (int i = 1; i <= 100; i += 2) {sum += i;}printf("The sum of all odd numbers within 100 is: %d\n", sum);return 0;}```2. 请编写一个函数,实现两个整数的交换。
```cvoid swap(int *a, int *b) {int temp = *a;*a = *b;*b = temp;}```以上是大一C语言考试题库及详解答案的正文内容。
大一c语言课后题答案

大一c语言课后题答案作为大一学生,很多同学在学习C语言的时候会遇到不少难题。
为了帮助大家提高C语言的学习效果,老师常常会布置一些课后作业,下面是一些常见的C语言课后题及其解答。
题目一:编写一个程序,找出1000以内的质数。
解答:#include <stdio.h>#include <math.h>int main(){int i, j, flag;for (i = 2; i <= 1000; i++){flag = 1; //假设i为素数for (j = 2; j <= sqrt(i); j++){if (i % j == 0) //如果存在因数则不是素数{flag = 0;break;}}if (flag == 1) //输出素数{printf("%d ", i);}}return 0;}题目二:编写一个程序,输入n,求1到n的阶乘之和。
解答:#include <stdio.h>int main(){int i, j, n, sum = 0, fac = 1;scanf("%d", &n);for (i = 1; i <= n; i++){for (j = 1; j <= i; j++) //求i的阶乘{fac *= j;}sum += fac; //计算阶乘之和fac = 1; //重置fac为1}printf("%d", sum);return 0;}题目三:编写一个程序,输入一个整数,判断它是否为水仙花数。
水仙花数是指一个n位数(n≥3),其各个位上数字的n次方之和等于其本身。
解答:#include <stdio.h>#include <math.h>int main(){int num, sum = 0, temp, n = 0;scanf("%d", &num);temp = num;//计算数字的位数while (temp != 0){n++;temp /= 10;}temp = num;//计算n次方之和while (temp != 0){sum += pow(temp % 10, n);temp /= 10;}//比较结果if (sum == num){printf("%d是水仙花数", num); }else{printf("%d不是水仙花数", num);}return 0;}以上就是三道C语言课后题的解答。
C语言课后习题参考答案

C语言课后习题参考答案第一章:基础知识问题1:C语言的发展历史及特点C语言是由贝尔实验室的肯·汤普逊和丹尼斯·里奇在20世纪70年代初开发的一种高级程序设计语言。
它以其简洁、高效和可移植性而闻名。
C语言被广泛应用于系统级编程、嵌入式系统和科学计算等领域,并成为其他编程语言的基础。
问题2:C语言的基本数据类型及其存储范围C语言的基本数据类型包括字符型(char)、整型(int)、浮点型(float)、双精度浮点型(double)和空类型(void)。
它们的存储范围如下:- char:-128 到 127 或 0 到 255- int:-32,768 到 32,767 或 0 到 65,535- float:3.4E-38 到 3.4E38- double:1.7E-308 到 1.7E308- void:无特定存储范围问题3:如何在C语言中输出语句?在C语言中,可以使用printf函数来输出语句。
它的基本语法为:```cprintf("要输出的内容");```问题4:定义变量的语法规则在C语言中,定义变量的语法规则如下:```c数据类型变量名;```例如,定义一个整型变量x:```cint x;```问题5:如何进行变量的赋值?变量的赋值可以使用赋值运算符(=)。
例如,将一个整型常量10赋值给变量x:```cx = 10;```第二章:控制结构问题1:if语句的语法结构if语句用于根据条件执行不同的代码块。
它的基本语法结构如下:```cif (条件) {// 条件为真时执行的代码}```问题2:switch语句的用法及语法结构switch语句用于根据不同的表达式值执行相应的代码块。
它的基本用法及语法结构如下:```cswitch (表达式) {case 值1:// 当表达式的值等于值1时执行的代码break;case 值2:// 当表达式的值等于值2时执行的代码break;default:// 当表达式的值与所有case都不匹配时执行的代码break;}```问题3:循环语句的分类及语法结构C语言中的循环语句包括for循环、while循环和do-while循环。
c语言课后答案 (2)

第7章数组习题解答一、在以下每一题的四个选项中,请选择一个正确的答案。
【题7.1】C【题7.2】D【题7.3】D【题7.4】D【题7.5】C【题7.6】C【题7.7】C【题7.8】C【题7.9】B【题7.10】B二、判断下列各叙述的正确性,若正确在()内标记√,若错误在()内标记×。
【题7.11】√【题7.12】√【题7.13】×【题7.14】×【题7.15】√【题7.16】×【题7.17】×【题7.18】×【题7.19】√【题7.20】×三、填空。
请在下面各叙述的空白处填入合适的内容。
【题7.21】字符数组【题7.22】0【题7.23】4【题7.24】按行的顺序存放【题7.25】48【题7.26】strcat( )【题7.27】6【题7.28】10【题7.29】strcmp( )C语言程序设计教程实验指导与习题解答【题7.30】#include <stdio.h>四、阅读下面的程序,写出程序运行结果。
【题7.31】abcdefgabcdefabcdeabcdabcaba【题7.32】1 11 2 11 2 3 11 2 3 4 1【题7.33】a[2]*b[1]=2a[4]*b[4]=16a[6]*b[7]=42【题7.34】10 1 2 3 4 5 6 7 8 9五、程序填空。
请在下面程序空白处填入合适的语句。
【题7.35】a[j++]=a[i]【题7.36】array[i]>array[j]六、编程。
对下面的问题编写程序并上机验证。
【题7.37】编写程序,用冒泡法对20个整数排序(按升序排序)。
/*lx7_1.c*/#include "stdio.h"#define N 20void main( ){ int data[N];int i,j,t;printf("请输入%d 个整数:\n",N);for(i=0;i<N;i++)scanf("%d",&data[i]);printf("\n");for(i=0;i<N; i++)for(j=0; j<N-i; j++)if(data[i]>data[j]){ t=data[i]; data[i]=data[j]; data[j]=t; }第一部分习题解答printf("排序后的输出为:\n");for(i=0;i<N; i++)printf("%d ",data[i]);}【题7.38】编写程序,将一个数插入到有序的数列中去,插入后的数列仍然有序。
大学C语言课本课后习题相应答案及详细解答

5-1#include"stdio.h" void main(){char c1,c2;printf("c1:");c1=getchar();if(c1>='a'&&c1<='z') c2=c1-32;else if(c1>='A'&&c1<='Z') c2=c1+32;else c2=c1;printf("=>%c\n",c2);}5-2#include"stdio.h"void main(){char c;printf("c:");c=getchar();if(c>='A'&&c<='Z')if(c=='A') printf("没有前面的字母!");else if(c=='Z') printf("没有后面的字母!!");else printf("前面的字母=%c,后面的字母=%c",c-1,c+1);printf("\n");} 5-3#include"stdio.h"void main(){int s;char g;printf("s:");scanf("%d",&s);if(s>=0&&s<=100){switch(s/10){case 9:case 10: g='A';break;case 8: g='B';break;case 7: g='C';break;case 6: g='D';break;default: g='E';}printf("g=%c\n",g);}else printf("成绩不在百分制范围内!\n"); }5-4#include"stdio.h"void main(){int y,m,d,dok;int yy,mm,dd;printf("y,m,d:");scanf("%d,%d,%d",&y,&m,&d);switch(m){case 1: case 3: case 5: case 7: case 8: case 10: case 12:if(d>0&&d<=31) dok=4;else dok=0;break;case 4: case 6: case 9: case 11:if(d>0&&d<=30) dok=3;else dok=0;break;case 2: if(y%4==0&&y%100!=0||y%400==0)if(d>0&&d<=29)dok=2;else dok=0;elseif(d>0&&d<=28)dok=1;else dok=0;break;default: dok=0;}if(dok==0) printf("月份或日期不对!\n");else{switch(dok){case 1: if(d==28){yy=y;dd=1;mm=m+1;}else{yy=y;dd=d+1;mm=m;}break;case2:if(d==29){yy=y;dd=1;mm=m+1;}else{yy=y;dd=d+1;mm=m;}break;case3:if(d==30){yy=y;dd=1;mm=m+1;}else{yy=y;dd=d+1;mm=m;}break;case 4:if(d==31)if(m==12){yy=y+1;dd=1;mm=1;}else{yy=y;dd=1;mm=m+1;}else{yy=y;dd=d+1;mm=m;}break;}printf("Tomorrow:%d年%d月%d日\n",yy,mm,dd);}}5-5#include"stdio.h"void main(){int a,b,c,t;printf("a,b,c:");scanf("%d,%d,%d",&a,&b,&c);if(a+b>c&&b+c>a&&a+c>b){if(a>b){t=a;a=b;b=t;}if(a>c){t=a;a=c;c=t;}if(b>c){t=b;b=c;c=t;}if(a==b&&b==c) printf("等边三角形.");else if(a==b||b==c||a==c) printf("等腰角形.");else if(c*c==a*a+b*b) printf("直角三角形.");else printf("任意三角形.");printf("\n");}else printf("不能构成三角形!\n");}6-1#include"stdio.h"void main(){int a,b,m,n,k;printf("m,n:");scanf("%d,%d",&m,&n);a=m;b=n;k=a%b;while(k){a=b;b=k;k=a%b;}printf("%d\n",(m*n/b));}6-2#include"stdio.h"void main(){int n;int i,j,s;printf("n=");scanf("%d",&n);for(i=1;i<=n;i++){s=0;for(j=1;j<i;j++)if(i%j==0) s=s+j;if(s==i) {printf("%d:",i);for(j=1;j<i;j++)if(i%j==0) printf("%d ",j);printf("\n");}}} 6-3#include"stdio.h"#include"math.h"void main(){double x,y,zd,zx,x1,x2;zd=zx=50;for(x=0;x<=2;x=x+0.2){y=2*pow(x,3)-3*pow(x,4)+6*pow(x,5)-4*x+50;if(y>zd){ zd=y;x1=x;}if(y<zx){ zx=y;x2=x;}}printf("x=%f,max=%f\n",x1,zd);printf("x=%f,min=%f\n",x2,zx);}6-4#include"stdio.h"void main(){double x,sum=0,a,b,c;int i;printf("x=");scanf("%lf",&x);a=x;b=1.0;c=1.0;for(i=1;i<=10;i++){sum=sum+a/(b*c);a=a*x*x;b=b+2;c=c*i;}printf("y(%.2lf)=%lf\n",x,sum);}7-1/*选择排序*/#include"stdio.h"void main(){int i,j,n,k,temp;int a[10];printf("n(<10):");scanf("%d",&n);printf("Original:");for(i=0;i<n;i++) scanf("%d",&a[i]);for(i=0;i<n-1;i++){ /*趟*/k=i;for(j=i+1;j<n;j++) /*比较次数*/if(a[j]<a[k]) k=j;/*<升序,>?*/if(k!=i){temp=a[i];a[i]=a[k];a[k]=temp;}}printf("Ordered:");for(i=0;i<n;i++) printf("%d ",a[i]);printf("\n");}7-2#include"stdio.h"void main(){int a[3][3];int i,j,s=1;printf("Input:\n");for(i=0;i<3;i++)for(j=0;j<3;j++){scanf("%d",&a[i][j]);if(i==j) s=s*a[i][j];}printf("s=%d\n",s);} 7-3/*杨辉三角*/#include"stdio.h"void main(){int x[7][7];int i,j;for(i=0;i<7;i++) {x[i][0]=1;x[i][i]=1;}for(i=2;i<7;i++)for(j=1;j<i;j++)x[i][j]=x[i-1][j]+x[i-1][j-1];for(i=0;i<7;i++){for(j=0;j<=i;j++)printf("%3d",x[i][j]);printf("\n");}}7-4#include<stdio.h>#include<string.h>void main(){char str[21];int i,j;printf("str:");gets(str);for(i=0,j=strlen(str)-1;i<=j;i++,j--)if(str[i]!=str[j]) break;if(i>j) printf("%s是回文\n",str);else printf("%s不是回文\n",str);}7-5/*输入一维数组的10个元素,并将最小值与第1个数交换,最大值与最后一个数交换,然后输出交换后的结果*/#include<stdio.h>void main(){int a[10],i,zx,zd;printf("Input:\n");zx=zd=0;for(i=0;i<10;i++){scanf("%d",&a[i]);if(a[i]<a[zx]) zx=i;if(a[i]>a[zd]) zd=i;}if(zx!=0){int t;t=a[0];a[0]=a[zx];a[zx]=t;}if(zd!=9){int t;t=a[9];a[9]=a[zd];a[zd]=t;}for(i=0;i<10;i++)printf("%d ",a[i]);printf("\n");} 8-2#include"stdio.h"double xexp(double x,int n){double c;if(n==0) c=1.0;else c=x*xexp(x,n-1);return c;}void main(){int n;double x;printf("x:");scanf("%lf",&x);printf("n:");scanf("%d",&n);printf("Result=%g\n",xexp(x,n));}8-3#include"stdio.h"int find(int x[],int n,int y){int i,pos=-1;for(i=0;i<n;i++)if(x[i]==y) pos=i;return pos;}void main(){int a[10]={11,1,13,15,18,7,19,27,3,8};int i,y,pos;for(i=0;i<10;i++) printf("%d ",a[i]);printf("\ny:");scanf("%d",&y);pos=find(a,10,y);if(pos==-1) printf("Not found!\n");else printf("Position=%d\n",pos);}8-1#include"stdio.h"#include"conio.h" //getch()#include"stdlib.h" //srand(),rand(),system("cls") #include"time.h" //time()void main(){void init(int a[][5],int m,int n);void input(int a[][5],int m,int n);void output(int a[][5],int m,int n);int min(int b[][5],int m,int n);int a[5][5],ch='0';while(1){system("cls"); //清屏printf("1.初始化 2.键盘输入0.结束程序:");printf("\n");if(ch=='0') break;else if(ch=='1'){init(a,5,5);output(a,5,5);}else if(ch=='2'){input(a,5,5);output(a,5,5);}else printf("Error!\n");printf("Min element:%d\n",min(a,5,5));printf("按任意键继续!\n");getch();}}void init(int a[][5],int m,int n){int i,j;srand(time(0)); //time(0)表示以当前的时间做种子,增加每次运行的随机性for(i=0;i<5;i++)for(j=0;j<5;j++)a[i][j]=rand()%100; //随机数范围:0~32767,将它控制在0~99的范围}void input(int a[][5],int m,int n){int i,j;printf("Input Array 5X5:\n");for(i=0;i<m;i++)for(j=0;j<n;j++)scanf("%d",&a[i][j]);}void output(int a[][5],int m,int n){int i,j;printf("Output Array 5X5:\n");for(i=0;i<5;i++){for(j=0;j<5;j++)printf("%2d ",a[i][j]);printf("\n");}}int min(int b[][5],int m,int n){int i,j,zx;zx=b[0][0];for(i=0;i<m;i++)for(j=0;j<n;j++)if(i==j&&b[i][j]<zx) zx=b[i][j];return zx;}8-4#include"stdio.h"float pave,nave;void saver(float a[],int n){int i,z,f;float psum,nsum;psum=nsum=0.0;z=f=0;for(i=0;i<n;i++)if(a[i]<0) {nsum=nsum+a[i];z++;}else if(a[i]>0) {psum=psum+a[i];f++;}else continue;pave=(z!=0?psum/z:0.0);nave=(f!=0?nsum/f:0.0);}void main(){float a[10]={1.0,11.0,3.0,-1.5,-5.5,-2};saver(a,10);printf("pave=%.1f,nave=%.2f\n",pave,nave); } 8-5#include"stdio.h"#include"math.h"void p1(int a,int b){printf("has two equal roots:%\n",-b/(2*a));}void p2(int a,int b, int disc){float x1,x2;x1=(-b+sqrt(disc))/(2*a);x2=(-b-sqrt(disc))/(2*a);printf("Has distant real roots:% and %\n",x1,x2);}void p3(int a,int b, int disc){float real,image;real=-b/(2*a);image=sqrt(-disc)/(2*a);printf("Has complex roots:\n");printf("%+%8.4fi\n",real,image);printf("%-%8.4fi\n",real,image);}void main(){ int a,b,c,disc;printf("a,b,c:");scanf("%d,%d,%d",&a,&b,&c);disc=b*b-4*a*c;if(fabs(disc)<=1e-6) p1(a,b);else if(disc>1e-6) p2(a,b,disc);else p3(a,b,disc);}8-6#include"stdio.h"#include"stdlib.h"#include"conio.h"#include"time.h"void main(){void printaverage(int score[][5],int m,int n);void printname(int score[][5],int m,int n);int score[10][5];int i,j;srand(time(0));for(i=0;i<10;i++)for(j=0;j<5;j++)score[i][j]=50+rand()%50+1;printf("Output Students' score:\n");printf("Course 1 2 3 4 5\n");printf("-------------------------\n");for(i=0;i<10;i++){printf("No.%2d:",i+1);for(j=0;j<5;j++)printf("%3d ",score[i][j]);printf("\n");}printaverage(score,10,5);printname(score,10,5);} void printaverage(int score[][5],int m,int n){int i,j,sum;printf("\nAverage score:\n");for(i=0;i<m;i++){sum=0;for(j=0;j<n;j++)sum=sum+score[i][j];printf("No.%d:%.1f\n",i+1,sum/5.0);}}void printname(int score[][5],int m,int n){int i,j,max0,row0;for(j=0;j<5;j++){max0=score[0][j];for(i=0;i<10;i++)if(score[i][j]>max0){max0=score[i][j];row0=i;}printf("Course %d,max score=%d,student:No.%d\n",j+1,max0,row0+1);}}大学英语I词汇练习题Choose the best one to complete each sentence.1. She felt like ____C___ frustration, but she was determined not to lose her self-control.A. to cry out ofB. to cry forC. crying out ofD. crying for2. The method he used turned out to be ___A____ in improving the students' English.A. effectiveB. abilityC. responseD. explicit3. Measures had to be taken in face of the housing problem that ____C____ in the city.A. foundedB. raisedC. aroseD. produced4. Without electronic computers, much of today's advanced technology ___D____.A. haven't been achievedB. wouldn't be achievedC. hadn't been achievedD. wouldn't have been achieved5. Jane said to her husband, "Don't worry. There is no cause for __B______ about our daughter'sability to manage herself."A. careB. concernC. attentionD. love6. The tap won't ____A____, and there is water all over the floor.A. turn offB. turn downC. turn onD. turn up7. Wearing the right shoes and clothes ____B____ being fit can make all the difference.A. in additionB. as well asC. alsoD. too8. She didn't try to do anything for her daughter, and ____B____ it's too late now.A. in caseB. in any caseC. at this caseD. in case of9. The girl said she hated _____C___ he smiled at her.A. that wayB. this wayC. the wayD. all the way10. I'll call the hotel. I'll tell them we'll ____A____ tomorrow morning and stay there for two nights.A. check inB. check outC. check offD. check over11. My father didn't go to New York; the doctor suggested that he ___C____ there.A. not to goB. won'tC. not goD. not to go to12. She _____C____ him to find answers to her problems.A. learned fromB. came intoC. leaned onD. subjected to13. The large wings of that bird ______B_____ it to fly high and fast.A. makeB. enableC. forceD. realize14. If he ____D___ the policeman honestly, he would not have been arrested.A. would answerB. answerC. should answerD. had answered15. I intended ___A____ you last Sunday, but I had no time.A. to have called onB. calling onC. to be calling onD. to be called on16. If you try to learn too many things at a time, you may get ____D___.A. alarmedB. scaredC. surprisedD. confused17. I haven't read this book, and my brother hasn't ____A____.A. eitherB. neitherC. alsoD. too18. No sooner ____B_____ than the truck started off.A. his luggage was loadedB. had his luggage been loadedC. loaded his luggageD. his luggage was being loaded19. At the end of the game, the whole crowd ____C____ their feet and cheered wildly.A. emerged fromB. rose fromC. got toD. stood up20. Darren has decided to give ___D_____ football at the end of this season.A. inB. forC. offD. up21. Neither his friends nor his mother ____B____ his marriage to that girl.A. acceptB. acceptsC. agreeD. agrees22. Most people believe that he is quite _____A___ of lying to get out of trouble.A. capableB. enabledC. ableD. skilled23. We were told that most of our luggage would be _____B___ by sea.A. approachedB. transportedC. handledD. communicated24. The Broadcasting Museum also offers Saturday workshops to _____B___ children with the world of radio.A. contriveB. acquaintC. acquireD. admit25. Without a passport, leaving the country is ____D___.A. out of questionB. without questionC. in the questionD. out of the question26. She states her views very ___A______.A. definitelyB. definiteC. infiniteD. infinitely27. You need to ____D____ the employers that you can do the job.A. convictB. confuseC. confirmD. convince28.The little boy was so lucky to have ___B_____ the earthquake.A. surviveB. survived C .surviving D. survival29. It is ___B___ that later in life you will see each other again.A. likeB. likelyC. likedD. seemed30.Women’s social ____B____ has changed much over the years.A. stateB. statusC. statesD. statement31.The novel _____D____ the imagination of thousands of readers.A. caterB. cateredC. captureD. captured32.There are good chances of ______D______ working in this firm.A. prospectB. portionC. positionD. promotion33.If you are ______A_____ a night owl, having the first class start in the afternoon might be thebest thing that could ever happen to you.A. more ofB. more thanC. much moreD. more34. The conference discussed the fair ______A_____of income and wealth.A. distributionB. distributeC. contributionD. contribute35. I was so ___C__ in today's history lesson that I didn't understand anything.A. amazedB. confusingC. confusedD. amazing36. ___B___ in England, Anne Bradstreet both admired and imitated several English poets.A. Having born and educatedB. Born and educatedC. Since born and educatedD. To be born and educated37. You will see this product ___B___ wherever you go.A. to be advertisedB. advertisedC. advertiseD. advertising38. I never forget my __B__ with you for the first time.A. to meetB. meetingC. to have metD. having to be meeting39.She was so angry that she left like __B__ something at him.A. to throwB. throwingC. to have thrownD. having thrown40. We are ___C__ in different kinds of extracurricular activities on campus.A. having involvedB. to involveC. involvedD. involving41.Let me assure you that it was not done ______D_____.A. intensiveB. intensivelyC. intentionalD. intentionally42.This medicine can ____A____ the pain in no time.A. lessenB. lessC. looseD. loosen43.Advertising is often the most ____A____ method of product promotion.A. effectiveB. effectedC. emotionalD. efficient44.It is at 5 a.m. _C___ the train from Beijing to Guangzhou will arrive.A. forB. withC. thatD. when45.Things might have been much worse if the mother _B___ on her right to keep the baby.A. has been insistingB. had insistedC. would insistD. insisted46.Had he worked harder, he __B__ the exams.A. must have got throughB. would have got throughC. permitted are freshmenD. are permitted freshmen47.God knows, how can I ____A____ six exams a week?.A. endureB. tolerateC. bear D .suffer48.All their attempts ______C______ the child from the burning building were in vain.A. rescuedB. to have rescueC. to rescueD. in rescuing49,Could you find someone ______C_______ for me to play tennis with?A. to fitB. fitC. fittingD. suit50. The smooth space flight marks a big ______D______ for Chinese scientists.A. breakB. breakingC. breakupD. breakthrough51 Economic crises destroy the capitalist system, and they grow in size and ____A____.A. durationB. duringC. endureD. enduringpanies will have to do more than this if they are to ___B_____ the earthquake.A. survivedB. surviveC. survivesD. surviving53. The baby felt ____C____ by her parents.A. hateB. loveC. ignoredD. ignore54. There are good chances of ______D______ in this firm.A. moveB. motiveC. motionD. promotion55. She tried to ______D______ our friendship.A. underminedB. keptC. maintainedD. undermine56. The new airport will ______C___ tourism.A. helpedB. useC. facilitateD. benefited57. They were full of ____B____ when they saw my new car.A. jealousB. envyC. pitifulD. loves58. This medicine can ____A____ the pain in no time.A. lessenB. lessC. leastD. little59.He _______A_____ her on her last physics paper.A. complimentedB. complimentC. completeD. completed60. Mrs. Hill is _______B____ on Tom’s marrying Susan.A. awareB. keenC. kindD. keep61. Let me assure you that it was not done ______C_____.A. internationalB. purposeC. intentionallyD. intentional62.The novel _____D_____ the imagination of thousands of readers.A. seizeB. catchC. captureD. captured63. If you yell ___A____ someone, you should apologize.A. atB. outC. ofD. under64. He came over and ____B____ a piece of paper into my hand.A. shoveB. shovedC. shovesD. shoving65. The girl student whose father is a senior engineer used to ___A____ abroad.A. studyB. studyingC. studiesD. studied66.The doctor tried to help ____D____ the function of his limbs.A. storeB. storesC. restoresD. restore67. Women’s social ____B____ has changed much over the years.A. placeB. statusC. landD. work68. It was he ___A___ knew he didn’t need to be afraid to make mistakes at that moment.A. whoB. whomC. whichD. whose69. A dropped cigarette is being ____C____ for the fire.A. firedB. fireC. blamedD. blame70. Advertising is often the most _____D___ method of promotion.A. effectB. affectC. affectedD. effective71.In time you’ll _____A_____ the beauty of this language.A. appreciateB. appreciatesC. appreciatedD. appreciating72. ______B___ is his favorite toy is hard for the kid to decide.A. whoB. whichC. howD. where73. After dinner, I took a ____A____ around the park.A. strollB. divingC. runD. walking74. The boy really enjoyed the useful and ____B____ work in science.A. creationB. creativeC. createdD. creator75. Some professions are _____A_______ with people who have not grown up.A. stuffedB. stuffC. stiffD. stiffed76. Economic crises destroy the capitalist system, and they grow in size and ____A____.A. durationB. duringC. endureD. enduring77. The new airport will ____C_____ tourism.A. helpedB. useC. facilitateD. benifited78. Let me assure you that it was not done _____C______.A. internationalB. purposeC. intentionallyD. intentional79. The girl student whose father is a senior engineer used to ___A____ abroad.A. studyB. studyingC. studiesD. studied80. Advertising is often the most ____D____ method of promotion.A. effectB. affectC. affectedD. effective81. It was he ___A___ knew he didn’t need to be afraid to make mistakes at that moment.A. whoB. whomC. whichD. whosepanies will have to do more than this if they are to _____B___ the earthquake.A. survivedB. surviveC. survivesD. surviving83. The baby felt ____C____ by her parents.A. hateB. loveC. ignoredD. ignore84. If you yell ___A____ someone, you should apologize.A. atB. outC. ofD. under85. Mrs. Hill is ______B_____ on Tom’s marrying Susan.A. awareB. keenC. kindD. keep86. _____A____ college takes hard work!A. SurvivingB. SurviveC. SurvivesD. To surviving87. It is absolutely ____A___ for the human beings to do something to save the earth.A. necessaryB. necessarilyC. unnecessaryD. unnecessarily88. An employer is more ____D____ to choose the candidate with high grades.A. likeB. probablyC. possiblyD. likely89. I don’t like this young woman. She seems a social ___D____.A. flowerB. workerC. negotiatorD. butterfly90. How should this ___B____ girl see the coldness of the letter?A. blindB. innocentC. warmD. pretty91. Be careful not to ___B____ yourself in their local conflicts.A. attendB. involveC. take part inD. participate92. Home prices are holding ____C___ in most regions, and people live with steady income.A. flexibleB. fierceC. stableD. shortage93. He was ______C______ by a newspaper reporter at that time.A. being interviewB. interviewC. being interviewedD. to interview94. They were full of ____C____ when they saw my new car.A. enviousB. envilyC. envyD. envies95. ________C_________, it is a very stable pattern producing results through effort .A. ContraryB. ConverseC. On the contraryD. Diverse96. The teacher doesn’t permit _____B____ in classA. smokeB. smokingC. to smokeD. to have a smoke97. The man in the corner confessed to ___A____ a lie to the manager of the company.A. have toldB. be toldC. being toldD. having told98. I never forget __B____ you for the first time.A. to meetB. meetingC. to have metD. having to be meeting.99. _______A___ a man has, ___________ he wants.A. The more, the moreB. More, moreC. The more, moreD. More, the more100. I see no _____B____ of his success.A. possibleB. possibilityC. possibilitiesD. probable101. He could be ____B____ about everything else in the world, but not about Manet, his loving child.A. visualB. criticalC. favoriteD. essential102. Some see themselves as the provider of ideas, ____C____ others view their role as essentially managerial.A. whenB. thereforeC. whileD. otherwise103. The idea ____A____ to him so much that he took it without hesitation.A. appealedB. interestedC. drewD. attracted104. The teacher evaluated the performance of each of his students who ____B____ evaluated his performance.A. by turnB. in turnC. at turnD. on turn105. Disease _____A____ during the journey and many passengers had to be rushed to hospital for treatment.A. broke outB. broke downC. started offD. started out106. The products have been _____A_____ to strict tests before leaving the factory.A. subjectedB. adjustedC. objectedD. constricted107. Our television set is out of order. Could you come and _____C_____ it for us?A. see throughB. see outC. see toD. see over108. _____C_____ they have taken matters into their hands, the pace of events has quickened.A. As thatB. So thatC. Now thatD. For that109. Our neighbor said if we made more noise he would _____B____ us to the police.A. inform ofB. complain aboutC. report toD. care for110. People working in the government should not _____A______ business affairs that might affect their political decisions.A. engage inB. hope forC. choose betweenD. pick on111. It's not easy to ______B______ to the top in show business.A. make outB. make itC. make upD. make them112. Carter is in charge of the office while I'm ______C______.A. leavingB. on leavingC. on leaveD. on relief113. We must ____B____ our attention on the question of reducing our cost.A. payB. focusC. absorbD. promote 114. Snap judgments, if ___B_____, have usually been considered signs of immaturity or lack of common sense.A. taking seriouslyB. taken seriouslyC. take seriouslyD. to be taken seriously115. Being with his family for a few days, I gained one or two insights ____A____ the reason he behaves the way he does.A. intoB. ofC. onD. off116. ___D___ your age or knowledge of the language, you'll be 100% involved in your studies from the first lesson to the last.A. As a result ofB. In spiteC. Despite ofD. Regardless of117. He said he had caught a bad cold and told me to ____D____ him.A. stay atB. stay upC. stay inD. stay away from118. Good managing of a company ___A_____ great efforts.A. calls forB. calls outC. calls inD. calls at119. I've looked ___C_____ all my papers but I still can't find the contract.A. uponB. outC. throughD. in120. When I'm going out in the evening I use the bike if I can, ___B_____ the car.A. regardless ofB. more thanC. other thanD. rather than121. We can't speak ___A____ our teacher.A. too highly ofB. too high ofC. highly of tooD. to highly of122. No one in our class ____D___ in sports than he.A. are more interestedB. are much interestedC. is much interestedD. is more interested123. As a teacher you have to ____B____ your methods to suit the needs of slower children.A. enlargeB. adjustC. affectD. afford124. ________A___ the hotel before soldiers armed with pistols and clubs charged into the crowd.A. Scarcely had they leftB. Scarcely they had leftC. Scarcely they leftD. Scarcely left they125. In the film, the peaceful life of a monk _____D_____ the violent life of a murderer.A. is compared withB. is compared toC. is contrasted toD. is contrasted with126 I didn't realize the food problem was so _____B___ in this city; with winter coming, many people would starve to death without more help.A. essentialB. criticalC. explicitD. effective127. Female socialization places importance on getting along with others, _____B___ male socialization places importance on becoming independent.。
《C语言程序设计教程》习题参考答案

《C语言程序设计教程》习题参考答案《C语言程序设计教程》习题参考答案祝胜林主编华南理工大学出版社【习题1】 (1)【习题2】 (2)【习题3】 (3)【习题4】 (5)【习题5】 (8)【习题6】 (11)【习题7】 (14)【习题8】 (17)【习题9】 (17)【习题10】 (20)一、简答题(在课本中寻找答案,略)1.1C程序的基本结构包括哪些内容?1.2如何定义标识符?1.3输入格式、输出格式的组成包括哪些内容?1.4C语言函数分为哪两类?1.5计算表达式的值应该考虑哪些方面?1.6上机调试程序的步骤如何?二、判断并改错1.7C程序执行的入口是main()函数,所以main函数必须放在程序的开头。
错误:main函数可以放在程序的任何位置。
并不限定在程序的开头。
1.8定义一个函数包括数据说明部分和执行语句部分,两者可以交叉出现。
错误:不可以交叉出现,数据说明部分在执行语句部分的前面。
1.9编辑与编译不是一回事。
错误:不是一回事。
编辑完成源程序的输入和修改;编译是对源程序进行语法检查,如果无语法错误,则生成目标程序。
1.10scanf("%d,%d",&x,&y);的正确输入格式:3,4<回车>。
正确1.11注释内容太多会影响程序的执行效率。
错误:不会影响程序的执行效率。
因为在编译时,编译系统将注释内容删除或用空格代替,所以注释内容不会编译到目标程序中。
1.12所有的数学公式可以直接出现在源程序中。
错误:数学公式需要转换成C语言能够接受的公式才能出现在源程序中。
三、编程题1.13在屏幕上输出自己名字的拼音。
提示:中文名字叫?张三?,对应的拼音为?Zhang San?,输出用printf()函数。
1.14 输入圆的半径,求圆的周长,并将结果保留两位小数输出到屏幕上。
提示:定义圆的半径r,圆的周长:2*3.14*r,输出结果保留2位小数可以用%.2f1.15输入两个整数,输出其中最大者。
常州大学大一c语言课后题答案

常州大学大一c语言课后题答案1. 对 for(表达式1; ;表达式3) 可理解为 (). [单选题]A:for(表达式1;0;表达式3)B:for(表达式1;1;表达式3)(正确答案)C:for(表达式 1;表达式1;表达式3)D:for(表达式 1;表达式3;表达式3)2. 下列语句的结果是().main(){ int j;j=3;printf("%d,",++j);printf("%d",j++);} [单选题] A:3,3B:3,4C:4,3D:4,4(正确答案)3. 整型变量x和y的值相等、且为非0值,则以下选项中,结果为零的表达式是(). [单选题]A:x || yB:x | yC:x & yD:x ^ y(正确答案)4. 为了避免在嵌套的条件语句 if-else 中产生二义性,C语言规定:else子句总是与 [单选题]A:缩排位置相同的ifB:其之前最近的if(正确答案)C:其之后最近的ifD:同一行上的 if5. 若有定义:int a=7;float x=2.5,y=4.7;则表达式x+a%3*(int)(x+y)%2/4的值是 [单选题]A:2.500000(正确答案)B:2.750000C:3.500000D:0.0000006. 以下程序段的输出结果为().char c[]="abc";inti=0;do;while(c[i++]!='\0');printf("%d",i-1); [单选题]A:abcB:abC:2D:3(正确答案)7. 若有以下程序:main(){int k=2,i=2,m;m=(k+=i*=k); printf("%d,%d\n",m,i);}执行后的输出结果是(). [单选题]A:8,6B:8,3C:6,4(正确答案)D:7,48. 下列程序的输出结果是().main(){ int x=1,y=0,a=0,b=0;switch(x){case 1:switch(y){case 0:a++;break;case 1:b++;break;}case 2:a++;b++;break; case 3:a++;b++;break;}printf("a=%d,b=%d\n",a,b);} [单选题]A:a=1,b=0B:a=2,b=1(正确答案)C:a=1,b=1D:a=2,b=29. 以下所列的C语言常量中,错误的是(). [单选题]A:0xFFB:1.2e0.5(正确答案)C:2LD:'\72'10. 以下叙述中不正确的是(). [单选题]A:表达式 a&=b等价于B:表达式 a|=b等价于C:表达式a!=b等价于a=a!b(正确答案)D:表达式a^=b等价于a=a^b11. 以下选项中合法的实型常数是(). [单选题]A:5E2.0B:E-3C:.2E0(正确答案)D:1.3E12. 以下程序的执行结果是().main(){ int w = 1, x = 2, y = 3, z = 4;w =( w <x ) ? x : w; w =( w < y ) ? y : w;w =( w < z ) ? z : w;printf( "%d " [单选题]A:1B:2C:3D:4(正确答案)13. 以下叙述正确的是(). [单选题]A:do-while语句构成的循环不能用其它语句构成的循环来B:do-while语句构成的循环只能用 break语句退出.C:用do-while语句构成的循环,在while后的表达式为非零时结束循D:用do-while语句构成的循环,在while后的表达式为零时结束循环(正确答案)14. 若有以下定义:char s='\092'; 则该语句(). [单选题]A:使s的值包含1个字符B:定义不合法,s的值不确定(正确答案)C:使s的值包含4个字符D:使s的值包含3个字符15. 下列数据中,为字符串常量的是(). [单选题]A:AB:"house"(正确答案)C:How do you do.D:$abc16. C语言源程序文件经过C编译程序编译连接之后生成一个后缀为()的可执行文件. [单选题]A:.cB:.objC:.exe(正确答案)D:.bas17. 若有以下程序段:int a=3,b=4; a=a^b;b=b^a;a=a^b;则执行以上语句后,a和b的值分别是(). [单选题]A:a=3,b=4B:a=4,b=3(正确答案)C:a=4,b=4D:a=3,b=318. 判断两个字符串是否相等,正确的表达方式是(). [单选题]A:while(s1==s2)B:while(s1= s2)C:while(strc mp(s1,s2)==0)(正确答案)D:while(strc mp(s1,s2)=0)19. C语言中表达逻辑"真"值的是(). [单选题]A:.T.B:0C:TrueD:非0的数(正确答案)20. 执行以下程序段后,输出结果和a的值是 ().int a=10;printf("%d",a++); [单选题] A:10 和 10B:10 和 11(正确答案)C:11 和 10D:11 和 1121. 在以下给出的表达式中,与 do-- while(E)语句中的(E)不等价的表达式是 [单选题] A:(!E==0)B:(E>0||E<0)C:(E==0)(正确答案)D:(E!=0)22. 若a是float型变量,b是unsigned型变量,以下输入语句中合法的是(). [单选题] A:scanf("%6.2f%d",&a,&b);B:scanf("%f%n",&a,&b);C:scanf("%f% 3o",&a,&b);(正确答案)D:scanf("%f% f",&a,&b);23. 执行下列语句后,a和b的值分别为().int a,b; a=1+'a'; b=2+7%-4-'A'; [单选题]A:-63,-64B:98,-60(正确答案)C:1,-60D:79,7824. 下列正确的标识符是(). [单选题]A:_do(正确答案)B:6aC:%yD:a+b25. 下列程序段的输出结果为().float x=213.82631;printf("%3d",(int)x); [单选题] A:213.82B:213.83C:213(正确答案)D:3.826. C语言程序中必须有的函数是(). [单选题]A:#include "stdio.h"B:main(正确答案)C:printfD:scanf27. int a=1,b=2,c=3;if(a>b)a=b;if(a>c)a=c;则a的值为(). [单选题]A:1(正确答案)B:2C:3D:不一定28. 已知x=43,ch='A',y=0;则表达式 (x>=y&&ch<'B'&&!y)的值是(). [单选题]A:0B:语法错C:1(正确答案)D:"假"29. 语句while(!E);中的表达式!E等价于(). [单选题]A:E==0(正确答案)B:E!=1C:E!=0D:E==130. 下列程序的输出结果为().main(){int m=7,n=4;floata=38.4,b=6.4,x;x=m/2+n*a/b+1/2;printf("%f\n",x);} [单选题]A:27.000000(正确答案)B:27.500000C:28.000000D:28.50000031. 下列变量中合法的是(). [单选题]A:B.C.TomB:3a6bC:_6a7b(正确答案)D:$ABC32. 设C语言中,int类型数据占2个字节,则 unsigned类型数据占(). [单选题]A:1个字节B:2个字节(正确答案)C:4个字节D:8个字节33. 先用语句定义字符型变量c,然后要将字符a赋给c,则下列语句中正确的是(). [单选题]A:c='a';(正确答案)B:c="a";C:c="97";D:C='97'34. 已知大写字母A的ASCII码是65,小写字母 a的ASCII码是97,则用八进制表示的字符常量'\101'是(). [单选题]A:字符A(正确答案)B:字符aC:字符eD:非法的常量35. 设a=12,且a定义为整型变量.执行语句 a+=a-=a*=a;后a的值为(). [单选题]A:12B:144C:0(正确答案)D:13236. 设变量定义为"int a, b;",执行下列语句时,输入(),则a和b的值都是10.scanf("a=%d, b=%d",&a, &b); [单选题]A:10 10B:10, 10C:a=10 b=10D:a=10, b=10(正确答案)37. 假设所有变量均为整型,表达式:a=2,b=5,a>b?a++:b++,a+b的值是(). [单选题] A:7B:8(正确答案)C:9D:238. int a=3,b=2,c=1;if(a>b>c)a=b;else a=c;则a的值为(). [单选题]A:3B:2C:1(正确答案)D:039. 以下标识符中,不能作为合法的C用户定义标识符的是(). [单选题]A:putchar(正确答案)B:_doubleC:_123D:INT40. 在一个C程序中(). [单选题]A:main函数必须出现在所有函数之B:main函数可以在任何地方出现(正确答案)C:main函数必须出现在所有函数之后D:main函数必须出现在固定位置41. 下列语句的输出结果是 ().printf("%d\n",(int)(2.5+3.0)/3); [单选题]A:有语法错误不能通过B:2C:1(正确答案)D:042. C语言的switch语句中case后(). [单选题]A:只能为常量B:只能为常量或常量表达式(正确答案)C:可为常量或表达式或有确定值的变量及表达式D:可为任何量或表达式43. 下列各m的值中,能使 m%3==2&&m%5==3&&m%7==2为真的是(). [单选题] A:8B:23(正确答案)C:17D:644. C语言源程序名的后缀是(). [单选题]A:exeB:c(正确答案)C:objD:cp45. 设 int x=1, y=1; 表达式(!x||y--)的值是(). [单选题]A:0B:1(正确答案)C:2D:-146. 以下叙述正确的是(). [单选题]A:可以把 define和if定义为用户标识符B:可以把 define定义为用户标识符,但不能把 if定义为用户标识符(正确答案) C:可以把if定义为用户标识符,但不能把 define定义为用户标识符D:define和if都不能定义为用户标识符47. 结构化程序设计所规定的三种基本控制结构是(). [单选题]A:输入、处理、输出B:树形、网形、环形C:顺序、选择、循环(正确答案)D:主程序、子程序、函数48. C语言中,double类型数据占(). [单选题]A:1个字节B:2个字节C:4个字节D:8个字节(正确答案)49. 下列字符序列中,可用作C标识符的一组字符序列是(). [单选题] A:S.b,sum,a verage,_aboveB:class,day,lotus_1,2dayC:#md,&12x,m onth,student_n!D:D56,r_1_2,name,_st_1(正确答案)50. 以下叙述中正确的是(). [单选题]A:构成C程序的基本单位是函数(正确答案)B:可以在一个函数中定义另一个函数C:main()函数必须放在其它函数之前D:所有被调用的函数一定要在调用之前进行定义。
(word完整版)C语言程序设计课后习题1-8参考答案

C语言程序设计课后习题1—8参考答案习题1参考答案一、简答题1、冯诺依曼计算机模型有哪几个基本组成部分?各部分的主要功能是什么?答:冯诺依曼计算机模型是由运算器、控制器、存储器、输入设备、输出设备五大功能部件组成的。
运算器又称算术逻辑部件,简称ALU,是计算机用来进行数据运算的部件。
数据运算包括算术运算和逻辑运算。
控制器是计算机的指挥系统,计算机就是在控制器的控制下有条不紊地协调工作的.存储器是计算机中具有记忆能力的部件,用来存放程序和数据.输入设备是用来输入程序和数据的部件。
输出设备正好与输入设备相反,是用来输出结果的部件。
2、简述计算机的工作原理。
答:计算机的工作原理可简单地概括为:各种各样的信息,通过输入设备,进入计算机的存储器,然后送到运算器,运算完毕把结果送到存储器存储,最后通过输出设备显示出来。
整个过程由控制器进行控制。
3、计算机软件系统分为哪几类?答:软件内容丰富,种类繁多,通常根据软件用途将其分为两大类:系统软件和应用软件。
系统软件是指管理、监控、维护计算机正常工作和供用户操作使用计算机的软件。
这类软件一般与具体应用无关,是在系统一级上提供的服务。
系统软件主要包括以下两类:一类是面向计算机本身的软件,如操作系统、诊断程序等。
另一类是面向用户的软件,如各种语言处理程序(像BC、VC等)、实用程序、字处理程序等。
在操作系统的基础上运行。
4、什么叫软件?说明软件与硬件之间的相互关系。
答:软件是指计算机程序及有关程序的技术文档资料。
两者中更为重要的是程序,它是计算机进行数据处理的指令集,也是计算机正常工作最重要的因素。
在不太严格的情况下,认为程序就是软件。
硬件与软件是相互依存的,软件依赖于硬件的物质条件,而硬件则需在软件支配下才能有效地工作.在现代,软件技术变得越来越重要,有了软件,用户面对的将不再是物理计算机,而是一台抽象的逻辑计算机,人们可以不必了解计算机本身,可以采用更加方便、更加有效地手段使用计算机。
大学生C语言课后习题全部答案详解

#include〈stdio.h>main(){int a,b,he,cha,ji;double shang;a=8;b=3;he=a+b;cha=a—b;ji=a*b;shang=(double)a/b;printf(”和=%d\n”,he);printf("差=%d\n”,cha);printf(”积=%d\n”,ji);printf("商=%f\n",shang);}#include<stdio。
h>main(){double r,h,v,pi;pi=3。
14;r=2。
5;h=3.5;v=pi*r*r*h;printf(”面积=%f\n”,v);}#include<stdio。
h>#include〈stdlib.h〉#include〈conio.h〉main(){char ch;system(”cls”);printf(”|—-—---—-—----——-————--—-|\n”);printf("|请输入编号(0-7)|\n");printf(”|————————-——----———------|\n");printf(”|1—-创建通讯录|\n”);printf("| 2—-显示通讯录|\n”);printf("| 3——查询通讯录|\n");printf("|4——修改通讯录|\n");printf("|5——添加通讯录|\n");printf(”|6——删除通讯录|\n");printf(”|7——排序通讯录|\n");printf("| 0——退出|\n");printf("|—————-—--——————--———----|\n");printf("请输入选项\n”);ch=getch();putch(ch);}#include〈stdio。
C语言课后习题答案(最终)

C语言课后习题答案(最终)第0章习题1. 将下列十进制数分别转化为二进制数、八进制数和十六进制数:(1)128 (2)511 (3)1024 (4)65535 (5)1048575 答:(1)10000000、200、80 (2)111111111、777、1FF (3)10000000000、2000、400(4)1111111111111111、177777、FFFF (5)11111111111111111111、3777777、FFFFF2. 将下列二进制数转化为十进制数和十六进制数:(1)1100110101B (2)101101.1011B 答:(1)821、335 (2)45.6875、2D.B3. 写出下列数的原码、反码、补码:15、-20、-27/32 答:(1)00001111、00000000、00001111 (2)10010100、11101011、11101100 (3)1.1101100、1.0010011、1.00101004. 16位无符号定点整数的数值表示范围为多少?8位补码的表示范围是多少?16位补码的表示范围是多少?答:5.1968年Dijkstra提出结构化程序设计的思想的原因是什么?简要回答结构化程序设计的经典定义。
答:结构化程序设计概念的提出主要是源于程序结构的层次性与模块化使得构造出来的软件具有良好的可理解性和可维护性,随着软件规模的扩大与复杂性的提高,程序的可维护性成为程序设计者们关注的重要问题之一。
如果一个程序的代码块仅仅通过顺序、选择和循环这3种基本控制结构进行连接,并且每个代码块只有一个入口和一个出口,则称这个程序是结构化的。
6.C程序在内存中存储在哪儿?计算机的内存空间是如何分区的?分区存放不同类型的数据的目的是什么?答:0~65535、-128~127、-32768~32767C语言程序属于应用程序,程序代码本身存放在应用程序区,程序运行时处理的数据存计算机的内存空间主要分为3个区:系统程序区、应用程序区和数据区,其中数据区放在应用程序数据区。
C语言教材课后习题参考答案.docx

}
}
}
4、
main()
{int i, a, min, max;
scanf(“%d" , &a);
min=a;max=a;
for(i=2;i<=100;i++)
{ scanf(“,&a);
if (a<min) min=a;
if (a>max) inax=a;
}
printf (<<Max=%d, Min=%d\nv, max, min);
3、存储单元、符号地址、内存地址
4、十、十六、八
5、double(双精度型)
6、8
7、5.500000
8、a二-32768
9、+0017,021,0x11
三、写程序运行结果
3257
32 57
7.8& -345.12,7. 8765,-345.1230
7.87654e+00,-3. 5e+02
a,97, 141,61
main()
{int x, y;
for(x=20;x<=100;x++)
for (y=20;y<=100;y++)
if(x*x+y二二1053&&x+y*y二二873)
printf (i(x=%dy=%d\n” , x, y);
}
7、
main()
{
long int k, g, s=0;
printf ("Please input an integer:,z);
Printf(is not a quadratic);
大一C语言课后习题答案

习题一一、填空题1.主函数/main、主函数/main、主函数/main2.声明部分、执行部分3.源程序4.由一个或多个函数5.最前面6./*和*/二、选择题1.C 2.B 3.A 4.C 5.C 6.C 7.A 8.B 9.B 10.B 习题二一、填空题1.scanf和printf函数2.标识符3.字母、数字、下划线、字母、下划线4.十进制、八进制、十六进制5.单撇号6.327.18,14,a8.123、45.09.67,G10.1030011.25 21 3712.n1=%d\nn2=%d\n二、选择题1.A 2.D 3.C 4.C 5.C 6.B 7.A 8.D 9.A 10.D 11.D 12.C 13.A 14.C习题三一、填空题1.0,非02.else 总是与它前面最近的、等待与else配对的if配对3.将下列条件写成C语言的逻辑表达式:(1)x<0&&y!=0(2)x%3==0&&x%7==0(3)a<0||b<0||c<0(4)x>0 && x<=10(5)ch>=’a’ && ch<=’z’ || ch>=’A’ && ch<=’Z’4. 2 15.5 46.-4二、选择题1.B 2.C 3.B 4.A 5.B 6.C 7.8.D 9.D 10.A 11.C 12.B习题四一、填空题1.102.363.34.死、05.66.2*i – 1、printf("\n")7.100 – i*5 –j*2、k>=08.43219.2.40000010.*#*#*#$二、选择题1.C 2.A 3.C 4.都不对(b值为8)5.B6.C 7.C 8.C 9.C 10.D11.A 12.B 13.D 14.B 15.C16.D 17.D 18.C 19.B 20.A 习题五一、填空题1.变量2.54,102,1713.scanf("%f%f%f",&a,&b,&c);4.05.A:12B:1811 , 8C:42, 1, 4 D:7 2, 3, 4 6.A:1 B:1 C:1 D:1 7.A:8 B:0 C:1 D:9 8.5,10 9.整型10.x>2&&x<3||x<-10二、选择题1.C 2.C 3.D 4.A 5.D6.A 7.A 8.D 9.C 10.B11.C 12.B 13.D 14.C 15.D三、编程题1、int result;result=i>j?1:(i==j?0:-1);2、#include <stdio.h>main(void){int n,i;char ch;//提示输入数据printf("请输入ch和n:\n");scanf("%c%d",&ch,&n);//判断输入数据的有效性while(n<=0){printf("输入n值有错误,请重新输入\n"); scanf("%c%d",&ch,&n);}//输出结果for(i=0;i<n;i++)printf("%c",ch);}#include <stdio.h>void main(void){float f;//提示输入数据printf("请输入实数f:\n"); scanf("%f",&f);//计算过程f=f-(int)f;//输出结果printf("小数部分为:%f",f); }#include <stdio.h>void main(void){int n,count=0;//提示输入数据printf("请输入一个整数:\n"); scanf("%d",&n);//处理n为负整数的情况if(n<0)n=-n;//计算过程while(n){count++;n=n/10;}//输出结果printf("输入整数的位数是:%d",count); }5、#include <stdio.h>void main(void){int n,count=0;//提示输入数据printf("请输入一个整数:\n");scanf("%d",&n);//判断n的正负,同时对于零值特殊处理if(n<0)printf("输入整数的是负数");else if(n>0)printf("输入整数的是正数");elseprintf("输入整数的零");//判断n的奇偶性if(n%2 == 0)printf("并且是偶数");elseprintf("并且是奇数");}习题六一选择题1 C2 B3 A4 D5 D6 B7 C8 A9 D 10 A11 A 12 B 13 D 14 A 15 B二填空题1 按行排序2 2,43 字符数组4 数组第一个元素地址5 06 1 5 92 6 103 7 114 8 127 *********8 *********912 13 3 14 6 4 110 abcde11 i=1 x[i-1]12 int flag, i scanf(”%s”,str1) str[i]!=str1[i]13 i<=10-j a[i]<a[i+1] t=a[i] a[i+1]=t 习题七一、填空题1.52.153.max=23,min=-4max=0,min=04.1365.first:11,3,9second:20,3,9third:20,3,5二、选择题1.A 2.A 3.C 4.D 5.A6.C 7.A 8.B 9.A 10.A11.B 12.A 13.B 14.D 15.D 习题八一、错,对,错,对,错,对,对二、1. 地址2. &3. *4. 0和NULL5. void6. 5 , 19, 12, 157. ‘\0’,s8. s+n-1, p1<p2, p2--9. ‘\0’,n++10. s[i]<’0’ || s[i]>’9’,‘\0’11. ch=f12. s=2413. s=xbcdBCD14. PEOPLEpeople and computer15. 80, -20三、1. A 2. C 3. AC 4. D 5. B 6~10 BDDAD11~15 DDBBC16~20 BBCAC。
C语言课后习题答案第八章

作业八:函数程序设计答案(一)选择题(30分)1.以下正确的函数定义形式是A__。
A)double fun(int x,int y)B)double fun(int x;int y)C)double fun(int x,int y);D)double fun(int x,y);2.以下正确的函数形式是D__。
A)double fun(int x,int y){ z=x+y; return z; }B)fun(int x,y){ int z; return z; }C)fun(x,y){ int x,y; double z; z=x+y; return z; }D)double fun(int x,int y){ double z; z=x+y; return z; }(重要)3.以下正确的说法是A__。
在C语言中A)实参和与其对应的形参各占用独立的存储单元B)实参和与其对应的形参共占用一个存储单元C)只有当实参和与其对应的形参同名时才共占用存储单元D)形参是虚拟的,不占用存储单元4.若调用一个函数,且此函数中没有return语句,则正确的说法是D__。
该函数A)没有返回值B)返回若干个系统默认值C)能返回一个用户所希望的函数值D)返回一个不确定的值(重要)5.以下不正确的说法是B__。
C语言规定A)实参可以是常量、变量或表达式B)形参可以是常量、变量或表达式C)实参可以为任意类型D)形参应与其对应的实参类型一致6.C语言规定,简单变量做实参时,它和对应形参之间的数据传递方式是B__。
A)地址传递B)单向值传递C)由实参传给形参,再由形参传回给实参D)由用户指定传递方式7.以下程序有语法性错误,有关错误原因的正确说法是C__。
main(){int G=5,k;void Prt_char();……k=Prt_char(G);……}A)语句void prt_char();有错,它是函数调用语句,不能用void 说明B)变量名不能使用大写字母C)函数说明和函数调用语句之间有矛盾D)函数名不能使用下划线8.C语言允许函数值类型缺省定义,此时该函数值隐含的类型是B__。
大一c语言答案

选择题
1. B 2. A 3. B 4. B 5. C 6. B
阅读程序,写结果
7. 12 8.13 9. *0**2*
10.
if(s>=90)
m=4;
else if(s>=80)
m=3;
else if(s>=70)
m=2;
else if(s>=60)
m=1;
else
m=0;
11.输入4个整数a,b,c,d,编写程序,将它们按从大到小顺序输出。
(4)用C语言可直接访问物理地址,能进行二进制位运算等操作,即可直接同机器硬件打交道。它具有“高级语言”和“低级语言”的双重特征,既能用于系统软件程序设计,又能用于通用软件程序设计。
(5)C语言生成的目标代码质量高、程序执行速度快。一般只比用汇编语言生成的目标代码的效率低20%左右。
(6)可移植性好。
习 题 3 (参考答案)
1.编程实现:用字符输入/输出函数输入3个字符,将它们反向输出。
参考代码(尽量运用本章所学知识)
#include <stdio.h>
main( )
{ char c1,c2,c3;
c1=getchar(); c2=getchar(); c3=getchar();
14.2,4,6,8,10, 15.46.000000 16.852
17.利用近似公式 求π的值,直到最后一项的绝对值小于10-6为止。
#include<stdio.h>
#include<math.h>
main()
{ double pi=0,i=1,j=1,k;
C语言-习题集参考答案全部

目录- 1 -目录第一章C语言基础知识参考答案 ................................................................................ - 2 - 第二章顺序结构参考答案.......................................................................................... - 5 - 第三章选择结构参考答案.............................................................................................. - 7 - 第四章循环结构参考答案............................................................................................ - 11 - 第五章函数参考答案................................................................................................ - 15 - 第六章指针参考答案.................................................................................................... - 18 - 第七章一维数组参考答案............................................................................................ - 21 - 第八章二维数组参考答案.......................................................................................... - 28 - 第九章字符串参考答案.......................................................................................... - 31 - 第十章对C语言的深入讨论参考答案 ....................................................................... - 33 - 第十一章结构体与共用体参考答案............................................................................ - 34 - 第十二章文件参考答案........................................................................................ - 35 -全国计算机等级考试二级教程C 语言习题集参考答案- 2 - 第一章C语言基础知识参考答案一,选择题1 C2 D3 A4 C5 A6 D7 C 分析:C答案以数字开头了8 D 分析:int 是关键字9 C 10 D 11 B12 D 分析:Visual C++6.0中int类型的变量占的字节数为4。
c语言全部章节习题答案

c语言全部章节习题答案C语言是一门广泛应用于计算机编程的高级编程语言。
它的简洁和强大使得它成为了许多程序员的首选语言。
然而,学习一门新的编程语言并不总是容易的,特别是对于初学者来说。
为了帮助那些正在学习C语言的人们,本文将提供C语言全部章节习题的答案,以期为读者提供一些指导和帮助。
在学习C语言时,习题是巩固所学知识的重要方式。
通过解决习题,学生可以加深对C语言的理解,并提高他们的编程技能。
然而,有时候习题的解答并不容易找到,特别是对于初学者来说。
因此,本文将提供C语言教材中的全部章节习题的答案,以供读者参考。
在第一章中,我们学习了C语言的基本概念和语法。
习题主要涉及变量的声明和赋值,以及简单的算术运算。
以下是第一章习题的答案:1. 声明一个整型变量x,并将其赋值为10。
答案:int x = 10;2. 声明一个字符型变量ch,并将其赋值为'A'。
答案:char ch = 'A';3. 声明两个整型变量a和b,并将其相加的结果赋值给变量c。
答案:int a = 5;int b = 3;int c = a + b;第二章主要介绍了C语言中的控制结构,如条件语句和循环语句。
以下是第二章习题的答案:1. 编写一个程序,判断一个整数是否为偶数。
如果是偶数,输出"Even",否则输出"Odd"。
答案:#include <stdio.h>int main() {int num;printf("Enter an integer: ");scanf("%d", &num);if(num % 2 == 0) {printf("Even");} else {printf("Odd");}return 0;}2. 编写一个程序,计算1到100之间所有偶数的和。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
5.5 4
6.-4
二、选择题
1.B 2.C3.B 4.A5.B6.C 7.8.D 9.D 10.A 11.C 12.B
习题四
一、填空题
1.10
2.36
3.3
4.死、0
5.6
6.2*i–1、printf("\n")
7.100–i*5–j*2、k>=0
8.4321
9.2.400000
10.*#*#*#$
C:4
2, 1, 4
D:7
2, 3, 4
6.A:1
B:1
C:1
D:1
7.A:8
B:0
C:1
D:9
8.5,10
9.整型
10.x>2&&x<3||x<-10
二、选择题
1.C2.C3.D4.A5.D
6.A7.A8.D9.C10.B
11.C12.B13.D14.C15.D
三、编程题
1、int result;
f=f-(int)f;
//输出结果
printf("小数部分为:%f",f);
}
4、
#include <stdio.h>
voidmain(void)
{
int n,count=0;
//提示输入数据
printf("请输入一个整数:\n");
scanf("%d",&n);
//处理n为负整数的情况
if(n<0)
11~15DDBBC
16~20BBCAC
习题一
一、填空题
1.主函数/main、主函数/main、主函数/main
2.声明部分、执行部分
3.源程序
4.由一个或多个函数
5.最前面
6./*和*/
二、选择题
1.C2.B3.A4.C5.C6.C7.A8.B9.B10.B
习题二
一、填空题
1.scanf和printf函数
2.标识符
3.字母、数字、下划线、字母、下划线
2.else总是与它前面最近的、等待与else配对的if配对
3.将下列条件写成C语言的逻辑表达式:
(1)x<0&&y!=0
(2)x%3==0&&x%7==0
(3)a<0||b<0||c<0
(4)x>0 && x<=10
(5)ch>=’a’ && ch<=’z’||ch>=’A’ && ch<=’Z’
二、选择题
1.C2.A3.C4.都不对(b值为8)5.B
6.C7.C8.C9.C10.D
11.A12.B13.D14.B15.C
16.D17.D18.C19.B20.A
习题五
一、填空题
1.变量
2.54,102,171
3.scanf("%f%f%f",&a,&b,&c);
4.0
5.A:1
2
B:18
11 , 8
7.‘\0’,s
8.s+n-1,p1<p2,p2--
9.‘\0’,n++
10.s[i]<’0’ || s[i]>’9’,‘\0’
11.ch=f
12.s=24
13.s=xbcdBCD
14.PEOPLEpeople and computer
15.80,-20
三、
1.A2.C3.AC 4.D5.B
6~10BDDAD
n=-n;
//计算过程
while(n)
{
count++;
n=n/10;
}
//输出结果
printf("输入整数的位数是:%d",count);
}
5、
#include <stdio.h>
voidmain(void)
{
int n,count=0;
//提示输入数据
printf("请输入一个整数:\n");
scanf("%d",&n);
scanf("%c%d",&ch,&n);
}
//输出结果
for(i=0;i<n;i++)
printf("%c",ch);
}
3、
#include <stdio.h>
voidmain(void)
{
float f;
//提示输入数据
printf("请输入实数f:\n");
scanf("%f",&f);
//计算过程
4.十进制、八进制、十六进制
5.单撇号
6.32
7.18,14,a
8.123、45.0
9.67,G
10.10300
11.25 21 37
12.n1=%d\nn2=%d\n
二、选择题
1.A2.D3.C4.C5.C6.B7.A8.D9.A10.D
11.D12.C13.A14.C
习题三
一、填空题
1.0,非0
4.136
5.first:11,3,9
second:20,3,9
third:20,3,5
二、选择题
1.A2.A3.C4.D5.A
6.C7.A8.B9.A10.A
11.B12.A13.B14.D15.D
习题八
一、错,对,错,对,错,对,对
二、
1.地址
2.&
3.*,19,12, 15
}
习题六
一选择题
1 C 2 B 3 A 4 D 5 D
6 B 7C8 A 9 D 10 A
11 A 12 B 13 D 14 A 15 B
二填空题
1按行排序
2 2,4
3字符数组
4数组第一个元素地址
5 0
61 5 9
2 6 10
3 7 11
4 8 12
7*****
*
*
*
*
8*****
*
*
*
*
9
1
2 1
//判断n的正负,同时对于零值特殊处理
if(n<0)
printf("输入整数的是负数");
else if(n>0)
printf("输入整数的是正数");
else
printf("输入整数的零");
//判断n的奇偶性
if(n%2 == 0)
printf("并且是偶数");
else
printf("并且是奇数");
3 3 1
4 6 4 1
10a
b
c
d
e
11 i=1 x[i-1]
12 int flag, i scanf(”%s”,str1) str[i]!=str1[i]
13i<=10-ja[i]<a[i+1] t=a[i] a[i+1]=t
习题七
一、填空题
1.5
2.15
3.max=23,min=-4
max=0,min=0
result=i>j?1:(i==j?0:-1);
2、
#include <stdio.h>
main(void)
{
int n,i;
char ch;
//提示输入数据
printf("请输入ch和n:\n");
scanf("%c%d",&ch,&n);
//判断输入数据的有效性
while(n<=0)
{
printf("输入n值有错误,请重新输入\n");