第六章单元测试
- 变量a所占的内存字节数是( )。
struct stu
{ char name[20];
long int n;
int score[4];
} a ; struct person{ char name[9]; int age;};
struct person calss[4]={ "Johu",17,
"Paul",19,
"Mary",18,
"Adam",16,};
根据这些定义,能输出字母M的语句是( )。- 以下程序的输出是( )。
struct st
{int x;int *y;} *p;
int dt[4]={10,20,30,40};
struct st aa[4]={50,&dt[0],60,&dt[0],60,&dt[0],60,dt[0],};
main()
{ p=aa;
printf("%d\n",++(p->x));
} - 以下程序的输出结果是( )。
struct HAR
{ int x,y; struct HAR *p; } h[2];
main()
{ int h[0].x=1; h[0].y=2;
h[1].x=3;h[1].y=4;
h[0].p=&h[1]; h[1].p=h;
printf("%d%d\n",(h[0].p)->x,(h[1].p)->y); } - 设有变量定义
struct stu
{int age;
int num;
}std,*p=&std;
能正确引用结构体变量std中成员age的表达式是( )。 - 若有以下说明语句:
struct student
{ int num;
char name[];
float score;
}stu;
则下面的叙述不正确的是( )。 - 若有以下说明语句:
struct date
{ int year;
int month;
int day;
}brithday;
则下面的叙述不正确的是( )。 - 已知:(设整型2字节,字符型1字节,浮点型4字节)
struct
{ int i;
char c;
float a;
}test;
则sizeof(test)的值是( )。 - 存放100个学生的数据、包括学号、姓名、成绩。在如下的定义中,不正确的是( )。
- 以下对结构变量stul中成员age的非法引用是( )。
struct student
{ int age;
int num;
}stu1,*p;
p=&stu1; - 设有如下定义:
struct sk
{ int a;
float b;
}data;
int *p;
若要使P指向data中的a域,正确的赋值语句是( )。
A:32 B:30 C:36 D:28
答案:32
A:printf("%c\n",class[2].name[1]); B:printf("%c\n",class[2].name[0]); C:printf("%c\n",class[3].name); D:printf("%c\n",class[3].name[1]);
答案:printf("%c\n",class[2].name[0]);
A:11 B:10 C:60 D:51
答案:51
A:12 B:14 C:23 D:32
答案:32
A:*p.age B:*std->age C:(*p).age D:std->age
答案:(*p).age
A:num, score都是结构体成员名 B:struct student 是用户定义的结构体类型 C:stu是用户定义的结构体类型名 D:struct是结构体类型的关键字
答案:stu是用户定义的结构体类型名
A:struct date 是用户定义的结构体类型名 B:brithday是用户定义的结构体类型名 C:struct是声明结构体类型时用的关键字 D:year,day 都是结构体成员名
答案:brithday是用户定义的结构体类型名
A:7 B:6 C:5 D:4
答案:7
A:struct student {int sno; char name[20]; float score;}; struct student stu[100]; B:struct {int sno; char name[20]; float score;} stu[100]; C:struct student {int sno; char name[20]; float score;} stu[100]; D:struct student stu[100] {int sno; char name[20]; float score};
答案:struct student stu[100] {int sno; char name[20]; float score};
A:stu1.age B:p->age C:(*p).age D:student.age
答案:student.age
A:*p=data.a; B:p=&data.a; C:p=data.a; D:p=&a;
答案:p=&data.a;