上海市c语言二级试卷及答案
一、选择题(每题2分,共40分)
1.下列哪个选项是C语言的基本数据类型?
A.string
B.int
C.boolean
D.object
答案:B
2.C语言中,用于定义一个整型变量的关键字是?
A.var
B.integer
C.int
D.type
答案:C
3.在C语言中,以下哪个运算符用于取模运算?
A.%
B./
C.
D.-
答案:A
4.C语言中,哪个关键字用于定义函数?
A.function
B.def
C.define
D.void
答案:B
5.在C语言中,以下哪个选项是正确的字符串声明?
A.charstr[]=Hello;
B.stringstr=Hello;
C.strchar=Hello;
D.charHellostr;
答案:A
6.C语言中,以下哪个选项是正确的数组声明?
A.intarray[5]={1,2,3,4,5};
B.intarray={1,2,3,4,5};
C.intarray[5]=1,2,3,4,5;
D.intarray=1,2,3,4,5;
答案:A
7.在C语言中,以下哪个选项是正确的条件语句?
A.if(x0){...}
B.ifx0{...}
C.if(x0)then{...}
D.ifx0then{...}
答案:A
8.C语言中,以下哪个选项是正确的循环语句?
A.while(x10){...}
B.loopx10{...}
C.repeatx10{...}
D.forx10{...}
答案:A
9.在C语言中,以下哪个选项是正确的函数调用?
A.print(Hello,World!);
B.printfHello,World!;
C.print(Hello,World!);
D.printf(Hello,World!);
答案:D
10.C语言中,以下哪个选项是正确的指针声明?
A.intptr;
B.intptr;
C.intptr;
D.ptrint;
答案:A
11.在C语言中,以下哪个选项是正确的结构体声明?
A.structStudent{intid;charname[50];};
B.structStudent:intid;charname[50];};
C.structStudent{intid;stringname;};
D.structStudent{intid;charname[50];intage;};
答案:D
12.C语言中,以下哪个选项是正确的枚举类型声明?
A.enumColor{Red,Green,Blue};
B.enum{Red,Green,Blue};
C.enumColor{1Red,2Green,3Blue};
D.enum{Red=1,Green=2,Blue=3};
答案:A
13.在C语言中,以下哪个选项是正确的宏定义?
A.definePI3.14159
B.definePI3.14159
C.definePI3.14159
D.definePI3.14159
答案:A
14.C语言中,以下哪个选项是正确的文件操作函数?
A.fopen
B.open
C.fileopen
D.file
答案:A
15.在C语言中,以下哪个选项是正确的动态内存分配函数?
A.malloc
B.alloc
C.memory
D.new
答案:A
16.C语言中,以下哪个选项是正确的位运算符?
A.
B.|
C.^
D.~
答案:D
17.在C语言中,以下哪个选项是正确的位域