2-1
For the following declarations,assignment expression_is not correct.
struct Student {
long num;
char name[28];
}st1,st2={101,"Tom"},*p=&st1;
〇 A.st1 =st2
◎ B.p->name =st2.name
O C p->num =st2.num
〇 D,*p=st2
2-2
下面定义结构变量的语句中错误的是()。
O A.struct student{int num;char name[20];}s;
O B.struct {int num;char name[20];}s;
O C.struct student(int num;char name[20]:};struct student s;
◎ D.struct student{int num;char name[20];};student s;
2-3
如果有以下定义语句,则输出结果为()。
struct {
int x,Y;
}s[2]={{1,3},{2,7}};
printf(“%d\n”,s[θ].y/s[1].x);
O A.0
◎ B.1
O c.2
O D.3
2-4
根据下面的定义,能打印出字母M的语句是()。
struct person
{
char name[10];
int age;
}c[10]={“John”,17,“Paul”,19,“Mary”,18,“Adam”,16 };
O A.printf(“%c”,c[3].name);
O B.printf(“%c”,c[3].name[1]);
◎ C.printf(“%c”,c[2].name[0]);
O D.printf(“%c”,c[2].name[1]);
2-5
设有以下说明语句:
struct stu
{
int a;
float b
}stutype
则下面的叙述不正确的是:
O A.struct是结构体类型的关键字
O B.struct stu是用户定义的结构体类型
◎ C.stutype是用户定义的结构体类型名
O D.a和b都是结构体成员名
2-6
定义如下结构体:
struct sk
{
int a;
float b;
}data,*p;
若指针p指向结构体变量data,即有p=&data;,则对结构体成员a的正确引用是__。
O A.(“p).data.a
◎ B.(*p)a
O C.p->data.a
O D.p.data.a
2-7
若程序中有下面的说明和定义,则会发生的情况是()。
struct ahe f
int x;
char y;
};
struct abc s1,s2;
O A.编译出错
◎ B.程序将顺利编译、连接、执行
○ C.能顺利通过编译、连接,但不能执行
O D.能顺利通过编译,但连接出错
2-8
对于以下定义,不正确的叙述是()。
struct ex {
int x;
float y;
char z
}example
O A.struct是定义结构类型的关键字
◎ B.example是结构类型名
O C.x,y,z都是结构成员名
O D.struct ex是结构类型名
2-9
以下程序段的输出结果为()。
struct {
int x;
int y;
}s[2]={{1,3 },{2,7}};
printf("%d",s[θ].y/s[1].x);
O A.0
◎ B.1
O c.2
○ D.3
2-10
设有如下定义,则错误的输入语句是()。
struct ss{
char name[10];
int age;
char sex;
}std[3],*p =std;
O A.scanf(“%d”,&(*p).age);
◎ B.scanf(“%d”,p->&age);
O C.scanf(“%c”,&std[0].sex);
O D.scanf(“%c”,&(p->sex));
2-11
下列程序的输出结果是()。
struct stu{
char num[1θ];
float score[3];
};
int main()
{
struct stu s[3]={{"20021",90,95,85},{"20022",95,80,75},{20023",100,95,90}};
struct stu *p =s;
int i;
float sum =θ;
for(i=8;i<3;i++){
SUN =SUm +0->scope/17
}
printf(“%6.2f”,sum);
return 0;
}
O A.260.00
◎ B.270.00
O C.280.00
O D.285.00
2-12
当定义一个结构变量时,系统分配给它的内存空间大小是()。
◎ A.各成员所需内存量的总和
O B.结构中第一个成员所需内存量
O C.成员中占内存量最大者所需容量
O D.结构中最后一个成员所需内存量
2-13
如果结构变量s中的生日是“1984年11月11日”,下列对其生日的正确赋值是()。
struct student
{
int no;
char name[28].
char sex;
struct{
int year;
int month;
int day;
Lbirth;
};
struct student s;
O A.year =1984;month =11;day=11;
O B.birthyear =1984;birth.month =11;birth.day =11;
O C.syear=1984;s.month=11;s.day=11;
◎ D.s.birth.year =1984;s.birth.month =11;s.birth.day=11;
2-14
C语言中结构类型变量在程序执行期间()。
◎ A.所有成员一直驻留在内存中
○ B.只有一个成员驻留在内存中
○ C.部分成员驻留在内存中
○ D.没有成员驻留在内存中
2-15
以下程序的输出结果是()。
struct stu[
int x;
int *y;
}*p;
int dt[4]={10,20,30,40};
struct stu a[4]={50,8dt[θ],60,&dt[1],70,&dt[2],88,&dt[3]};
int main()
{
p=a;
printf("%d,",++p->x);
printf("%d,",(++p)->x);
printf("%d",++(*p->y));
return θ;
}
O A.10,20,20
O B.50,60,21
◎ C.51,60,21
O D.60,70,31
2-16
以下定义结构变量的语句中,错误的是()。
O A.
struct student{
int num;
char name[20];
}s;
O B.
struct {
int num
char name[20];
}s;
◎ C.
struct student{
int num;
char name[28];
};
student s;
O D.
struct student{
int num;
char name[28];
};
struct student s;
2-17
以下程序段的输出结果为()。
struct {
int x,y;
}s[2]={{1,3},{2,7}};
printf("%d\n",s[θ].y/s[1].x);
O A.0
◎ B.1
O C.2
O D.3
2-18
根据下面的定义,能打印出字母N的语句是()。
struct personf
char name[10];int age;}c[10]={"John",17,"Paul",19,"Mary",18,"Adam",16 };
O A.printf(“%c”,c[3].name);
O B.printf(“%c”,c[3].name[1]);
◎ C.printf(“%c”,c[2].name[0]);
O D.printf(“%c”,c[2].name[1]);
2-19
若有以下说明语句,
struct birthday
{
int year;
int month;
int day;
}day1;
则下面叙述正确的是()。
O A.day1为结构体类型名
O B.struct birthday为结构体变量名
○ C.month为结构体变量名
◎ D.day1为结构体变量名
2-20
定义下列结构体数组:
struct stu
{char name[10];
int age;
}a[5]={"ZHAO",14,"WANG",15,"LIU",16,"ZHANG",17};
执行语句printf(“%d,%s”,a[2].age,a[1].name)的输出结果为()。
O A.15,ZHAO
O C.17,LIU
◎ B.16,WANG
O D.17,ZHAO