第八章测试1.
08110012:有以下说明语句,则下面的叙述不正确的是( )。
typedef struct stu{
int a;
float b
}stutype;
A:a和b都是结构体成员名 B:stutype是用户定义的结构体类型名 C:struct stu是用户定义的结构体类型名 D:struct是结构体类型的关键字
答案:B
2.
08110021:当说明一个结构体变量时系统分配给它的内存是( )。
A:各成员所需内存量的总和 B:成员中所占内存量最大者所需的容量 C:结构体中第一个成员所需内存量 D:结构体中最后一个成员所需内存量 3.
08110032:下列输出字符‘M’的语句是()。
struct person{
char name[9];
int age;
};
struct person class[10]={"John",17,"paul",19,"Mary",18,"Adam",16};
A: printf("%c",class[2].name[1]); B:printf("%c",class[2].name[0]); C:printf("%c",class[3].name[1]); D: printf("%c",class[3].name); 4.
08110042:下列关于结构体变量操作中正确的是()。
struct student{
char num[10];
char name[20],sex;
int age;
float score[3];
float ave;
};
A: stu2={"2008002","GaoPing",'M',18,86.3,80.5,89.4,85.4}; B:if (stu1==stu2) C: printf("%10s %20s %c %3d %4.1f %4.1f %4.1f %4.1",stu1); D:struct student stu1={"2008001","LiNing",'M',19,84.3,82.5,89.4,85.4}; 5.
08110052:以下定义结构体类型的变量st1,其中不正确的是()。
A: struct{
int num;
float age;
}st1;
int num ,age;
}st1;
int num;
int age;
}STD;
STD st1;
int num;
int age;
};
student st1;
08110062:已知职工记录描述为:
struct workers{
int no;
char name[20];
char sex;
struct{
int day;
int month;
int year;
}birth;
};
struct workers w;
设变量w中的“生日”应是“1993年10月25日”,下列对“生日”的正确赋值方式是()。
A:w.day=25;w.month=10;w.year=1993; B:w.birth.day=25;w.birth.month=10;w.birth.year=1993; C:day=25;month=10;year=1993; D:birth.day=25;birth.month=10;birth.year=1993; 7.
08210012:当说明一个共用体变量则系统分配给它的内存是( )。
A:所有成员一直驻留在内存中 B:只有一个成员驻留现在内存中 C:没有成员驻留在内存中 D:部分成员驻留在内存中 8.
08310012:设有枚举类型定义:enum color={red=3,yellow,blue=10,white,black};
其中枚举量black的值是()。
A:12 B:7 C:15 D:14 9.
08310022:关于下面变量赋值不正确的是()。
enum NUM{zero,first,second}num1;
int num2;
A:num1=0;num2=zero; B:num1=zero;num2=0; C:num1=0;num2=0; D:scanf(“%d%d”,&num1,&num2); 10.
08310032:如下说明语句:
enum A{A0=1,A1=3,A2,A3,A4,A5};
enum A b;
执行b=A3;printf(“%d”,b);输出是()。
A:3 B:编译出错 C:5 D:2