C语言试题

合集下载

C语言试卷(含答案)

C语言试卷(含答案)

一、单项选择题(每小题2分,共40分)1、sizeof(float)是()A. 一个双精度型表达式B. 一个整型表达式C. 一种函数调用D. 一个不合法的表达式2、设 i 是int 型变量,f 是float 型变量,用下面的语句给这两个变量输入值: scanf("i=%d,f=%f",&i,&f);为了把100 和分别赋给i 和f,则正确的输入为()。

A. 100B.i=100,f=765.12C. 100<回车>D. x=100y=3、#include<>voidmain(){inta=3,b=2,c=1;intx=10,y=20;if(a<b)if(b!=0)if(!x)y=1;elseif(x)y=0;y=-1;printf("%d",y);} 上面的C 程序的输出结果是()。

A. 20B.1C.0D.-14、C 语言中,while 和do …while循环的主要区别是()。

A. do …while的循环体至少无条件执行一次B. while 的循环控制条件比 do …while的循环控制条件严格C. do …while允许从外部转到循环体内D. do …while的循环体不能是复合语句5、执行下面的 C 程序段后,输出结果是()。

inta=5;while(a--);printf("%d",a);A. 54321B. 4321C.0D.-16、在 C 语言中,()是在所有函数外部声明的。

A. 全局变量B. 局部变量C.形参D.实参7、分析下面的 C 程序:#include<>voidmain(){intnum=0;while(num<=2){num++;printf("%d",num);}}输出结果是()。

A. 123B. 012C.23D.128、下面的 C 语言代码段的输出结果是()。

(完整word)C语言考试试题.

(完整word)C语言考试试题.
A.int max(x,y);B.static char c;C.#define PI 3。141592D.#define S 345
24.C语言中要求对变量作强制定义的主要理由是(B)
A.便于编辑预处理程序的处理B。便于确定类型和分配空间
C.便于移植D.便于写文件
25。以下数据中,不正确的数值或字符常量是(A)
25.若有定义:char s[]= ”turboC ";则Turbo C系统为数组s开辟【7】个字节的内存单元
二、判断共10题(共计20分)
1.inti,*p=&i;是正确的C说明(√)
2。若有说明intc;则while(c=getchar());是正确的C语句(√)
3。共同体变量所占的内存长度等于最长的成员长度(√)
23.当a=5,b=7,c=8时,执行以下程序段后c=【5】
if(a〈c) b=a;
a=c;
c=b;
24.已知a=5,写出表达式(0<a)‖(a〈2)的值是【1】
25。在TC2。0中,有以下结构类型说明和变量定义,则变量a在内存所占字节数是【22】
Strut stud
{char num[6];
int s [4];
4.charc[]=”Very Good”;是一个合法的为字符串数组赋值的语句(√)
5.在程序中定义了一个结构体类型后,可以多次用它来定义具有该类型的变量(√)
6。整数—32100可以赋值给int型和longint型变量(√)
7.如果函数值的类型和return语句中表达式的值不一致,则以函数类型为准(√)
for(i=0;i〈=2;i++)printf(“YES");printf(“\n”);

C语言试题

C语言试题

C语言习题精选第一章、程序设计基本概念一.选择题1.C语言规定,必须用(C)作为主函数(A)function (B)include (C)main(D)stdio2.一个C程序可以包含任意多个不同名的函数,但有且仅有一个(B),一个C程序总是从(B)开始执行。

(A)过程(B)主函数(C)函数(D)include3.! C源程序是由(A)构成的(A)函数(B)函数和过程(C)超文本过程(D)子程序4.(A)是C程序的基本构成单位(A)函数(B)函数和过程(C)超文本过程(D)子程序5.! 下列说法正确的是(C)(A)一个函数的函数体必须要有变量定义和执行部分,二者缺一不可(B)一个函数的函数体必须要有执行部分,可以没有变量定义(C)一个函数的函数体可以没有变量定义和执行部分,函数可以是空函数(D)以上都不对6.下列说法正确的是(D)(A)main函数必须放在C程序的开头(B)main函数必须放在C程序的最后(C)main函数可以放在C程序的中间部分,即在一些函数之前在另一个函数之后,但在执行C程序时是从程序开头执行的(D)main函数可以放在C程序的中间部分,即在一些函数之前在另一些函数之后,但在执行C程序时是从main函数开始的7.下列说法正确的是(C)(A)在执行C程序时不是从main函数开始的(B)C程序书写格式严格限制,一行内必须写一个语句(C)C程序书写格式自由,一个语句可以分写在多行上(D)C程序书写格式严格限制,一行内必须写一个语句,并要有行号8.在C语言中,每个语句和数据定义是用(C)结束(A)句号(B)逗号(C)分号(D)括号9.下列字符串是标识符的是(A)(注:以字母或下划线开头)(A)_HJ (B)9_student (C)long(D)LINE 110.以下说法正确的是(C)(A)C语言程序总是从第一个定义的函数开始执行(B)在C语言程序中,要调用的函数必须在main()函数中定义(C)C语言程序总是从main()函数开始执行(D)C语言程序中的main()函数必须放在程序的开始部分11.(B)不是C语言提供的合法关键字()(A)switch (B)print (C)case(D)default12.C语言提供的合法关键字是(A)(A)break (B)print (C)funition(D)end13.C语言提供的合法关键字是(A)(A)continue (B)procedure (C)begin(D)append二.填空题1.一个C源程序至少包含一个(主函数),即(main())2.!一个函数由两部分组成,它们是(函数的说明部分)和(函数体)3.!函数体一般包括(变量的定义部分)和(执行部分)4.!函数体的范围是(最外层的一对大括弧内的部分)5.!C语言是通过(输入和输出函数)来进行输入和输出的6.!在C语言中,凡在一个标识符后面紧跟着一对圆括弧,就表明它是一个(函数)7.C语言的关键字都用(小写){大写或小字}8.!主函数名后面的一对圆括号中间可以为空,但一对圆括号不能(省)第二章、 C程序设计的初步知识一.选择题1.C语言中不能用来表示整常数的进制是(D)(A)十进制(B)十六进制(C)八进制(D)二进制2.在C语言中,反斜杠字符是(D)(A)\n (B)\t (C)\v (D)\\3.在ASCII代码表中可以看到每一个小写字母比它相应的大写字母的ASCII码(A)(A)大32 (B)大64 (C)小32 (D)小14.设d为字符变量,下列表达式不正确的是(C)(A)d=97 (B)d=‟a‟ (C)d=”a”(D)d=‟g‟5.10+‟a‟+1.5-567.345/‟b‟的结果是(B)(A)long (B)double (C)int (D)unsigned float6.!在C语言中,运算对象必须是整型数的运算符是(A)(A)% (B)/ (C)%和/ (D)**7.为表示关系x>=y>=z,应使用C语言表达式(A)(A)(y<=x)&&(y>=z) (B)(x>=y)AND(y>=z)(C)(x>=y>=z) (D)(x>=y)&(y>=z)8.若欲表示在if后a不等于0的关系,则能正确表示这一关系的表达式为(D)(A)a<>0 (B)!a (C)a=0 (D)a!=09.?下列常数中,合法的C常量是(A)(A)”x-y” (B)‟105‟ (C)‟Be‟ (D)7ff10.?下列常数中,合法的C常量是(A)(A)-0. (B)‟105‟ (C) …AB‟(D)3+511.下列常数中,合法的C常量是(A)(A)‟\n‟ (B)e-310 (C)‟DEF‟ (D)‟1234‟12.下列常数中,不合法的C常量是(B)(A)-0x2a1 (B)lg3 (C)‟[… (D)”CHINA”13.下列常数中,不合法的C常量是(B)(A)-0x3b1 (B)123e+2.3 (C)‟}‟ (D)6e+714.?下列符号中,可以作为变量名的是(C)(A)+a (B)12345e (C)a3B (D)5e+015.写出下面程序的输出结果(A)main(){int x,y,z;x=y=1;z=x++-1;printf(“%d,%d\t”,x,z);z+=-x+++(++y||++z);printf(“%d,%d”,x,z);}(A)2,0 3,-1 (B)2,1 3,0 (C)2,0 2,1 (D)2,10 ,116.写出下面程序的输出结果(D)main(){int x=40,y=4,z=4;x = y = =z;printf(“%d”,x);x = x = = (y-z);printf(“%d”,x);}(A)4 0 (B)4 1 (C)1 1 (D)1 017.写出下面程序的输出结果(A)main(){int I,j;I=16; j=(I++)+I;printf(“%d”,j);I=15;printf(“%d %d”,++I,I);}(A)32 16 15 (B)33 15 15 (C)34 15 16(D)34 16 1518.若已定义x和y为double类型,则表达式:x=1,y=x+3/2的值为(C)(A)1 (B)2 (C)2.0 (D)2.519.?下列程序的执行结果是(B)#define sum 10+20main(){ int b=0,c=0;b=5;c=sum*b;printf(“%d”,c);}(A)100 (B)110 (C)70 (D)15020.表达式(double)(20/3)的值为(B)(A)6 (B)6.0 (C)2 (D)3二.填空题1.如果int I=3;则k=(I++)+(I++)+(I++),则k =(9),I=(6);2.?如果int I=3;则k=(I++)+(++I)+(I++),则k=(12), I=(6);3.?如果int I=3;则k=(++I)+(++I)+(I++),则k=(15),I=(6);4./如果int I=3;则k=(++I)+(++I)+(++I),则k=(18),I=(6);5.已知在ASCII字符集中,字母A的序号为65,下面程序的输出结果为(K,5)main(){char c=‟A‟; int I=10;c = c+10;I = c%I;Printf(“%c,%d\n”,c,I); }6.!C语言的数据类型有四大类,其分别为(基本数据类型),(构造类型),(指针),(空类型)。

C语言试题库(完整版)

C语言试题库(完整版)

C语言试题库一、单项选择第一章C语言概述(1)一个C程序的执行是从A、本程序的MAIN函数开始,到MAIN 函数结束.B、本程序文件的第一个函数开始,到本程序文件的最后一个函数结束。

C、本程序的MAIN函数开始,到本程序的最后一个函数结束。

D、本程序文件的第一个函数开始,到本程序的MAIN函数结束。

(2)以下叙述正确的是A、在C程序中,MAIN函数必须位于程序的最前面.B、C程序的每行中只能写一条语句。

C、C语言本身没有输入输出语句。

D、在对一个C程序进行编译的过程中,可发现注释中的拼写错误。

(3)C语言规定,在一个源程序中,MAIN主函数的位置是在:A、必须在最前面。

B、必须在系统调用的库函数的后面C、可以在任意位置。

D、必须在最后面(4)一个C程序是由:A、一个主程序和若干子程序组成B、函数组成C、若干过程组成D、若干子程序组成(5)以下叙述不正确的是:A、一个C源程序可由一个或多个函数组成B、一个C源程序必须包含一个MAIN函数C、C程序的基本组成单位是函数D、在C程序中,注释说明只能位于一条语句的后面第二章数据类型、运算符与表达式(1)若x,i, j,k都是int型变量,则计算下面表达式后,x的值为x=( i=4, j=16,k=32)A、4B、16C、32D、52(2)下列四组选项中,均不是C语言键字的选项是A、define ,IF,typeB、getc,char, printfC、include,scanf,caseE、i f, struct, type(3)下面四个选项中,均是不合法的用户标识符的选项是A、A,P_0,doB、float,1a0,_AC、b—a, goto,intD、_123, temp,INT(4)若有代数式3ae/bc,则正确的C语言表达式是A、a/b/c*e*3B、3*a*e/bcC、3*a*e/b*cD、a*e/c/b*3(5)已知各变量的类型说明如下:int k, a,b;unsinged long w=5;double x=1。

c语言期末试题及答案及详解

c语言期末试题及答案及详解

c语言期末试题及答案及详解一、选择题(每题2分,共20分)1. 下列哪个选项是C语言中的关键字?A. defineB. caseC. functionD. include答案:B2. C语言中,用于定义一个结构体的关键字是:A. structB. unionC. enumD. typedef答案:A3. 若有以下代码:```cint a = 5, b = 10;a = a + b;b = a - b;a = a - b;```执行后变量a的值是:A. 5B. 10C. 15D. 0答案:B4. 下列关于指针的描述,错误的是:A. 指针可以指向一个变量B. 指针可以指向一个数组C. 指针可以指向一个函数D. 指针不可以指向一个指针答案:D5. 在C语言中,以下哪个函数用于将字符串从源字符串复制到目标字符串?A. strcpyB. strcatC. strcmpD. strlen答案:A6. 下列哪个选项是C语言中合法的数组声明?A. int arr[5] = {0, 1, 2, 3, 4};B. int arr[] = {0, 1, 2, 3, 4};C. int arr[5] = {0, 1, 2};D. int arr[] = {0, 1, 2, 3};答案:B7. C语言中,以下哪个运算符用于执行按位与操作?A. &&B. ||C. &D. &&答案:C8. 下列关于函数的描述,正确的是:A. C语言中的函数可以没有返回值B. C语言中的函数可以返回多个值C. C语言中的函数可以重载D. C语言中的函数可以嵌套定义答案:A9. 在C语言中,以下哪个选项是正确的文件操作函数?A. fopenB. fcloseC. fgetcD. All of the above答案:D10. 下列关于C语言中循环的描述,错误的是:A. for循环可以嵌套使用B. while循环可以和do-while循环嵌套使用C. do-while循环至少执行一次D. break语句可以跳出循环体答案:B二、填空题(每题2分,共20分)1. 在C语言中,用于定义一个整型变量的关键字是________。

C语言程序设计期末考试试题及答案

C语言程序设计期末考试试题及答案

C语言程序设计期末考试试题及答案一、选择题(每题2分,共20分)1. C语言中,以下哪个关键字用于定义一个结构体?A. structB. unionC. enumD. typedef答案:A2. 下列关于C语言函数的描述中,正确的是?A. 函数可以没有返回值B. 函数可以有多个返回值C. 函数可以没有参数D. 函数必须有参数答案:C3. 在C语言中,以下哪个运算符用于取地址?A. *B. &C. %D. #答案:B4. 下列关于数组的描述中,错误的是?A. 数组可以是多维的B. 数组的下标从0开始C. 数组的大小在编译时确定D. 数组可以动态分配答案:D5. C语言中,以下哪个关键字用于定义一个指针?A. intB. charC. *D. void答案:C6. 在C语言中,以下哪个关键字用于定义一个静态变量?A. staticB. externC. registerD. auto答案:A7. 下列关于C语言中文件操作的描述中,正确的是?A. 文件操作只能使用标准库函数B. 文件指针必须使用FILE类型C. 文件操作必须使用fclose函数关闭文件D. 文件操作不能使用缓冲区答案:B8. 在C语言中,以下哪个关键字用于定义一个宏?A. defineB. typedefC. enumD. struct答案:A9. 下列关于C语言中位运算的描述中,错误的是?A. & 表示按位与B. | 表示按位或C. ^ 表示按位异或D. ~ 表示按位取反答案:B10. 在C语言中,以下哪个关键字用于定义一个枚举类型?A. enumB. structC. unionD. typedef答案:A二、填空题(每题2分,共20分)1. 在C语言中,一个整型变量占用的内存空间通常是______个字节。

答案:42. C语言中,使用______关键字可以定义一个无限循环。

答案:while3. C语言中,数组的元素默认初始化为______。

C语言试题库(含答案)

C语言试题库(含答案)
C、Print f("%c\n",class[2].name[l]);
D、print f("%c\n",class[2].name[0]);
标准答案:D
【5】设单精度变量f,g的值均为5.0,则下面的表达式中,使f为10.0的表达式是。
A、f+=g
B、f-=g+5
C、f*=g-5
D、f/=g*5
标准答案:A
if(ch=='/')w=a/b;
B、B)if(ch=='*')w=a*b;
else if(ch=='/')w=a/b;
if(ch=='+')w=a+b;
else if(ch=='-')w=a-b;
C、if(ch=='+')w=a+b;
else if(ch=='-')w=a-b;
if(ch=='*')w=a*b;
A、15
B、10
C、25
D、20
标准答案:A
【15】程序段的基本结构中,不包含()。
A、函数结构
B、循环结构
C、顺序结构
D、分支结构
标准答案:A
【1】执行语句scanf("%d,%d",&m,&n);使m和n的值分别为1和2,正确输入是。
A、1
B、2
C、1,2
D、12
标准答案:c
【3】若用数组名作为函数调用的实参,传递给形参的是()。
#include<stdio.h>
main()
{int i=1;

C语言200道练习试题和答案

C语言200道练习试题和答案

A)<=
B)=
C)%
D)&&
26.表达式(a=2,3) , a+1的值是【 C 】。
A)0 B)2
C)3
D)4
27.若执行printf("%d\n", strlen("a\n\"\x41"))语句其输 出结果是【 D 】。
A)8 B)7 C)6
D)4
28.在循环语句的循环体中执行break语句, 其作用是【 A 】。 A)跳出该循环体,提前结束循环 B)继续执行break语句之后的循环体各语句 C)结束本次循环,进行下次循环 D)终止程序运行
则输出是【 d 】 A)1234.56 1234 B)1234.57 1235 C)1234.56 1235 D)1234.57 1234
43.如果有
int a, b; scanf(“%d,%d”, &a, &b);语句,
则输入数据时,只可以用【 d 】作为输入的分隔符
A)TAB键 B)空格
C)回车
C)20,10 D)20,20
24.若有以下定义和语句 char c1='b',c2='e'; printf("%d,%c\n",c2-c1,c2-'a'+"A"); 则输出结果是【 B 】。
A)2,M B)3,E C)2,E D)输出项与对应的格式控制不一致,输出结果不确定
25.在以下一组运算符中,优先级最高的运算符是【 C 】
int i,j,k; scanf(“%d,%3d%d”,&i,&j,&k); printf(“%d,%d,%d\n”,i,j,k); A)12345678 B)123,456,78 C)123,45678 D)123,*45678
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

一、Select one answer from the four answers:(for each question, a total of 30 points)1.Which of the following expressiong is the equivalent to k=n++? ( ).A) k=n,n=n+1 B)n=n+1,k=n C)k=++n D)k+=n+12.What will be the printed output of the following program? ( ).main( ){ int x=10,y=10;printf("%d %d\n",x--,--y);}A)10 10 B) 9 9 C) 9 10 D) 10 93.Choose the correct output that following program produces. ( ).main(){ int x;x=-3+4*5-6; printf("%d",x);x= 3+4%5-6; printf("%d",x);x=-3*4%6/5; printf("%d",x);x=(7+6)%5/2; printf("%d",x);}A) 11 1 0 1 B) 11 -3 2 1 C) 12 -3 2 1 D)11 1 2 14. The printed output of the following program is ( ).#include <stdio.h>main(){ int y=10;do{y--;}while(--y);printf("%d\n",y--);}A) -1 B) 1 C) 8 D) 05. The printed output of the following program is ( ).#include <stdio.h>main(){ int i,b,k=0;for(i=1;i<=5;i++){ b=i%2;while(b-->=0) k++;}printf("%d, %d",k,b);}A) 3, -1 B) 8, -1 C) 3, 0 D) 8, -26.The correct expression to determain whether ch is a capital letter is( ).A) 'A'<=ch<='Z' B) (ch>='A')&&(ch<='Z')C) (ch>='A')&(ch<='Z') D) (ch>='A')AND(ch<='Z')7.Given a program as follows,the output will be( ) if data ADescriptor<CR>is keyed in when the program is running.#include <stdio.h>main(){ char c;int v0=0,v1=0,v2=0;do{switch( c=getchar()){ case 'a': case 'A':case 'e': case 'E':case 'i': case 'I':case 'o': case 'O':case 'u': case 'U': v1+=1;default: v0+=1; v2+=1;}}while(c!='\n');printf("v0=%d,v1=%d,v2=%d",v0,v1,v2);}A)v0=7,v1=4,v2=7; B)v0=8,v1=4,v2=8;C)v0=11,v1=4,v2=11; D)v0=12,v1=4,v2=12;8.Given the declarationsint a[][3]={1,2,3,4,5,6,7,8,9}the size of the first dimension of array a is ().A) 2 B) 3 C) 4 D) 59.The return type of the following program is( ).seed(double y){double z;z=x/2+5;return y;}A)int B)uncertain C)void D)float10. The following program will print out( ).main(){int m=5;if(m++>5) printf("%d\n",m);else printf("%d\n",m--);}A) 4 B) 5 C) 6 D) 711. Perform the following program. The printed output will be ( )if 3 is keyed in.#include<stdio.h>main(){int k;scanf("%d",&k);switch(k){case 1:printf("%d\n",k++);case 2:printf("%d\n",k++);case 3:printf("%d\n",k++);case 4:printf("%d\n",k++);break;default:printf("FULL!\n");}}A)3 B)4 C) 3 D) 44 512.The printed output of the next program is( ).#include<stdio.h>main(){int k=4,m=1,p;p=func(k,m);printf(“%d,”,p);p=func(k,m);printf(“%d\n”,p);}int func(int a,int b){static int m=0,i=2;i+=m+1;m=i+a+b;return m;}A)8,17 B)8,16 C)8,20 D)8,813.The valid function declaration in the following is ().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);14. The printed output of the following program is( ). main(){ int a=100,x=10,y=20,ok1=5,ok2=0;if(x<y)if(y!=10)if(!ok1) a=1;else if(ok2) a=10;a=-1;printf("%d\n",a);}A) 1 B) 0 C) -1 D) 215.The printed output of the following program is( ). main(){int x[5]={2,4,6,8,10},*p,**pp;p=x; pp=&p;prin tf(“%d”,*p++);printf(“%3d\n”,**pp);}A)4 4 B)2 4 C)2 2 D)4 616.Given the declaration:int a[3][4];the legal reference to an element of array a is ( ).A) a[2][4] B)a[1,3] C)a[1+1][0] D)a(2)(1)17.Given the declaration:int a[5],*p;p=a;the correct reference to the element of array a is ( ).A) *&a[5] B)a+2 C) *(p+5) D) *(a+2)18. Give the following declarationsint k; int a[3][3]={1,2,3,4,5,6,7,8,9};the output of statementfor(k=0;k<3;k++) printf("%d",a[k][2-k]);is ( )A) 3 5 7 B) 3 6 9 C) 1 5 9 D)1 4 719.The printed output of the following program is ( ). main{ int a[6][6],i,j;for(i=1;i<6;i++)for(j=1;j<6;j++)a[i][j] = (i/j)*(j/i);for(i=1;i<6;i++){ for(j=1;j<6;j++)printf("%2d",a[i][j]);printf("\n");}}A)1 1 1 1 1 B)0 0 0 0 1 C)1 0 0 0 0 D)1 0 0 0 11 1 1 1 1 0 0 0 1 0 0 1 0 0 0 0 1 0 1 01 1 1 1 1 0 0 1 0 0 0 0 1 0 0 0 0 1 0 01 1 1 1 1 0 1 0 0 0 0 0 0 1 0 0 1 0 1 01 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 120.Give a structure defination and a structure variable s declaration as follows:structure student{ int no;char name[20];char set;struct{ int year;int month;int day;}birth;};if structure member birth is going to be initialized as Nov. 11 1984, the legal assignments in the following is ().A) year=1984;B) birth.year=1984;month =11; birth.month=11;day=11; birth.day=11;C)s.year=1984; D)s.birth.year=1984;s.month=11; s.birth.month=11;s.day=11; s.birth.day=11;二、Filling in Blanks:(1 points for each blank,total of 10 points)1. Given that a=3,b=2,c=1, the value of expression【1】2. Suppose letter A’s ASCII code is 65 in decimal. What’s the output 【2】of the following:printf(“%d”,’A’+’5’-’3’);3.Assume a, b and c are all of type int, after the evalution of the following expression, a=(b=4)+(c=2); the a’s value is 【3】, b’s value is 【4】.4.Let binary number x=11001101, if you want to set the leftmost 4 bits of x to 0-bits and leave the remaining bits unchanged by bitwise operation x&y, the binary number y needs to be 【5】5. The following program will print out 【6】.#include <stdio.h>main(){int i =0;while(i!=3){i++;}printf(“%d”,i);}6. The following program will print out 【7】.#include <stdio.h>main(){int i;for(i=0;i<5;i++){if(i= =2)continue;}printf(“%d”,i);}7. Given the declaration as follows:int m=5,y=2;the value of y after the evaluation of y+=y-=m*=y is 【8】8.Assume a is a variable of type int, after the evaluation of the following expression,a=25/3%3the value of a is 【9】9. Give the declarationint a[3]={1,2,3};the initializer for a[1] is 【10】三、Ture of False?(1 points for each blank,10 points)1.All variables must be given a type when they are declared. ( )2.The conditional test !e in while(!e); is equivalent to e= =0. ( )3.Like variables, constants have a type.( )4.Character constants are code using double quotes.( )5.In C language, any nonzero value represents logical value “true”. ( )6.The following for statement will loop 123 times( )for(x=0,y=0;(y=123)&&(x<4);x++,y++);7.Variables declared in a function are valid in the function only. ( )8. a=2>3?3:2; the value of a is 3.( )9.Assuming that the type of y is int, the expression (y%2)= =1 means “y is an odd number”.( )10.An expression statement is terminated with a period. ( )(2 points for each blank, a total of 4 points)1.The output result of the below program is【1】#include<stdio.h>main(){ int a,b,s=0;for(a=1,b=1;a<=100;a++){ if(b>=20) break;if(b%3==1){b+=3; continue;}b-=5;}printf(“a=%d\tb=%d\n”,a,b);}2. The output result of the below program is 【2】#include<stdio.h>int func(int a, int b){return (a+b);}main(){ int x=2,y=5,z=8,r;r=func(func(x,y),z);printf(“%d\n”,r);} Array五、Filling in the blanks and finish the program:(for each blank, a total of 26 points)1.The following Program will compute the value of 20items of the follow series:2/1,3/2,5/3,8/5,13/8,21/13,….Please fill in the blanks to complete the Program.#include<stdio.h>int main(){int n,t;float a=2,b=1,s=0;for(n=1;【1】;n++){s=【2】;t=a;a=【3】;b=t;}printf(“s=%f\n”,s);return 0;}2. The following Program is designed to output an array a with 4 elements in a line. Please fill in the blanks to complete the program.#include<stdio.h>int main(){int a[12],i;for(【4】;i<12;i++)scanf(“%d”,【5】);for(i=0;i<12;i++){if(【6】)printf(“\n”);printf(“%d”,【7】);}printf(“\n”);return 0;}3. The following function max_2 is designed to return the maximum of two numbers, Please fill in the blanks to complete the program.#include<stdio.h>【8】;int main(){int num1=10,num2=20;max-2(【9】, 【10】);printf("maximum = %d\n", num1);return 0;}void max_2(int *data1,int *data2){if(*data1<*data2 )【11】;}4.Enter an integer from the keyboard, the statistics of the number of bits. For example, input 12534, output 5; input -99, output 2; input 0, output 1.#include<stdio.h>int main(void){int number,count;count=0;printf("Enter an integer:\n");scanf("%d",&number);if(number<0)number=-number;do{number=【12】;count++;}while(【13】);printf("the integer is %d bits.\n",count);return 0;}(5 points for each title, a total of 20 points)1)Enter a number, Determine the parity number. Forinput “1” ,output “The number is odd” ; input “2”, output “The number is even”2) Write a program and type two positive integers a and n, seeking the sum of a + aa + aaa + aa .... a (the a total of n) . For example, the inputs 2 and 3, the output 246 (2 + 22 + 222).3) Compile and compose procedure , enter the radius and height , seek a cylinder volume (). Requirements definition and calling function cylinder(r,h), calculate the volume of a cylinder.4) Enter 5 integers, they will be stored in the array a, then x input number , and then in the array to find x, if found, output "Found!".otherwise, output "Not Found!".Input: 2 9 8 1 99Output: Found!Input: 2 9 8 1 67Output: Not Found!。

相关文档
最新文档