专科c语言考试题及答案_第1页
专科c语言考试题及答案_第2页
专科c语言考试题及答案_第3页
专科c语言考试题及答案_第4页
专科c语言考试题及答案_第5页
已阅读5页,还剩10页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

专科c语言考试题及答案一、选择题(8题,每题3分,共24分)

1.下列哪个不是C语言的数据类型?

A.int

B.float

C.boolean

D.char

2.C语言中,用于动态分配内存的函数是?

A.malloc

B.free

C.realloc

D.BothAandC

3.以下哪个语句是正确的?

A.if(x==y)thenx=5;

B.if(x==y)x=5;

C.ifx==yx=5;

D.Alloftheabove

4.以下哪个是C语言中的循环语句?

A.while

B.for

C.do-while

D.Alloftheabove

5.C语言中,用于声明数组的符号是?

A.[]

B.()

C.{}

D.<>

6.以下哪个是正确的字符串定义?

A.charstr[]="Hello";

B.charstr="Hello";

C.charstr[6]="Hello";

D.Alloftheabove

7.在C语言中,哪个运算符用于求余数?

A.%

B./

C.*

D.+

8.以下哪个是正确的函数定义?

A.voidfunc(intx,inty)

B.intfuncx,y

C.func(intx,inty):int

D.intfunc(intx,y)

二、(一)多项选择题(5题,每题4分,共20分)

1.下列哪些是C语言的基本数据类型?

A.int

B.float

C.char

D.string

E.double

2.以下哪些是C语言中的循环语句?

A.while

B.for

C.do-while

D.if

E.switch

3.以下哪些是正确的数组声明?

A.intarr[5];

B.chararr[]="Hello";

C.floatarr[10]={1.0,2.0,3.0};

D.intarr[]={1,2,3,4,5};

E.chararr[5]={'H','e','l','l','o'};

4.以下哪些是C语言中的运算符?

A.+,-,*,/

B.%,&&,||

C.==,!=,>

D.<,>=,<=

E.!,~

5.以下哪些是正确的函数定义?

A.voidfunc(intx,inty)

B.intfuncx,y

C.func(intx,inty):int

D.intfunc(intx,y)

E.voidfunc()

(二)判断题(5题,每题2分,共10分)

1.C语言中,变量必须先声明后使用。()

2.C语言中的字符串可以用单引号括起来。()

3.C语言中的数组大小必须为正整数。()

4.C语言中的if语句必须有else部分。()

5.C语言中的switch语句可以处理字符串。()

三、(一)填空题(5题,每题4分,共20分)

1.在C语言中,用于声明常量的关键字是________。

2.C语言中,用于退出当前函数的函数是________。

3.C语言中,用于声明指向函数的指针的关键字是________。

4.C语言中,用于声明结构体的关键字是________。

5.C语言中,用于声明联合体的关键字是________。

(二)计算题(5题,每题6分,共30分)

1.写一个C语言程序,声明一个整型变量x,并初始化为5,然后输出x的值。

2.写一个C语言程序,声明一个浮点型变量y,并初始化为3.14,然后输出y的值。

3.写一个C语言程序,声明一个字符型变量c,并初始化为'A',然后输出c的值。

4.写一个C语言程序,声明一个字符串变量str,并初始化为"Hello",然后输出str的值。

5.写一个C语言程序,声明一个数组arr,包含5个整型元素,并初始化为1,2,3,4,5,然后输出数组的所有元素。

四、综合题(2题,每题12分,共24分)

1.写一个C语言程序,实现一个简单的计算器,可以加、减、乘、除四种运算。

2.写一个C语言程序,实现一个简单的学生成绩管理系统,可以添加、删除、修改、查询学生的成绩。

五、材料分析题(2题,每题14分,共28分)

1.分析以下C语言代码的功能:

```c

#include<stdio.h>

intmain(){

inti;

for(i=0;i<10;i++){

printf("%d\n",i);

}

return0;

}

```

2.分析以下C语言代码的功能:

```c

#include<stdio.h>

structStudent{

charname[50];

intage;

floatscore;

};

intmain(){

structStudents1;

s1.age=20;

s1.score=90.5;

printf("Name:%s\n",);

printf("Age:%d\n",s1.age);

printf("Score:%.2f\n",s1.score);

return0;

}

```

答案部分:

一、选择题

1.C

2.D

3.B

4.D

5.A

6.A

7.A

8.A

二、(一)多项选择题

1.A,B,C,E

2.A,B,C

3.A,B,C,D,E

4.A,B,C,D,E

5.A,E

(二)判断题

1.√

2.×

3.√

4.×

5.×

三、(一)填空题

1.const

2.return

3.functionpointer

4.struct

5.union

(二)计算题

1.

#include<stdio.h>

intmain(){

intx=5;

printf("%d\n",x);

return0;

}

2.

#include<stdio.h>

intmain(){

floaty=3.14;

printf("%f\n",y);

return0;

}

3.

#include<stdio.h>

intmain(){

charc='A';

printf("%c\n",c);

return0;

}

4.

#include<stdio.h>

intmain(){

charstr[]="Hello";

printf("%s\n",str);

return0;

}

5.

#include<stdio.h>

intmain(){

intarr[5]={1,2,3,4,5};

inti;

for(i=0;i<5;i++){

printf("%d",arr[i]);

}

printf("\n");

return0;

}

四、综合题

1.

#include<stdio.h>

intmain(){

intx,y,result;

charoperator;

printf("Enteranoperator(+,-,*,/):");

scanf("%c",&operator);

printf("Entertwooperands:");

scanf("%d%d",&x,&y);

switch(operator){

case'+':

result=x+y;

break;

case'-':

result=x-y;

break;

case'*':

result=x*y;

break;

case'/':

result=x/y;

break;

default:

printf("Invalidoperator\n");

return1;

}

printf("Result:%d\n",result);

return0;

}

2.

#include<stdio.h>

#include<string.h>

structStudent{

charname[50];

intage;

floatscore;

};

voidaddStudent(structStudentstudents[],int*count){

structStudents;

printf("Entername:");

scanf("%s",);

printf("Enterage:");

scanf("%d",&s.age);

printf("Enterscore:");

scanf("%f",&s.score);

students[*count]=s;

(*count)++;

}

voiddeleteStudent(structStudentstudents[],int*count){

charname[50];

printf("Enternametodelete:");

scanf("%s",name);

inti;

for(i=0;i<*count;i++){

if(strcmp(students[i].name,name)==0){

for(intj=i;j<*count-1;j++){

students[j]=students[j+1];

}

(*count)--;

break;

}

}

}

voidmodifyStudent(structStudentstudents[],intcount){

charname[50];

printf("Enternametomodify:");

scanf("%s",name);

for(inti=0;i<count;i++){

if(strcmp(students[i].name,name)==0){

printf("Enternewage:");

scanf("%d",&students[i].age);

printf("Enternewscore:");

scanf("%f",&students[i].score);

break;

}

}

}

voidqueryStudent(structStudentstudents[],intcount){

charname[50];

printf("Enternametoquery:");

scanf("%s",name);

for(inti=0;i<count;i++){

if(strcmp(students[i].name,name)==0){

printf("Name:%s\n",students[i].name);

printf("Age:%d\n",students[i].age);

printf("Score:%.2f\n",students[i].score);

break;

}

}

}

intmain(){

structStudentstudents[100];

intcount=0;

intchoice;

do{

printf("1.AddStudent\n");

printf("2.DeleteStudent\n");

printf("3.ModifyStudent\n");

printf("4.QueryStudent\n");

printf("5.Exit\n");

printf("Enteryourchoice:");

scanf("%d",&choice);

switch(choice){

case1:

addStudent(students,&count);

break;

case2:

deleteStudent(students,&count);

break;

case3:

modifyStudent(students,count);

break

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论