又到了期末周,突击一下c++吧@—@
第一次实验
1、已知学生记录的定义为:
struct student
{
int no;
char name[20];
char sex;
struct 注意年月日都是结构体,不是student里面的
{
int year;
int month;
int day;
}birth;
};
struct student s;
假设变量s中的"生日"应是"1988年5月10日",对"生日"的正确赋值语句是 【 正确答案: d】
(A) year=1988; month=5; day=10;
(B) brith.year=1988; birth.month=5; birth.day=10;
(C) s.year=1988; s.month=5; s.day=10;
(D) s.birth.year=1988; s.birth.month=5; s.birth.day=10;
2、直接打
已知:
union u_type
{
int i;
char ch;
}temp;
执行语句"temp.i=305;"后,temp.ch的值为 【 正确答案: D】
(A) 266 (B) 256 (C) 10 (D) 1
3、设有以下说明语句: 【 正确答案: c】
struct strutype
{
int a;
float b;
}var;
则下面叙述中错误的是
(A) struct是结构类型的关键字
(B) struct strutype是用户定义的结构类型
(C) var是用户定义的结构类型名
(D) a和b都是结构成员名
(A) struct
是结构类型的关键字 - 正确。在 C 语言中,struct
确实是用来定义结构体类型的关键字。
(B) struct strutype
是用户定义的结构类型 - 正确。这里 struct strutype
定义了一个名为 strutype
的结构体类型。
(C) var
是用户定义的结构类型名 - 错误。var
并不是结构类型名,而是该结构体类型的一个变量名。struct strutype
是结构类型名,而 var
是这个类型的一个实例或对象。
(D)