第八章测试1.
有如下结构体定义,能够正确引用结构体的是()。
struct student
{
long num;
char name[10];
char sex;
int age;
float score;
}stu;
A:
stu->sex=’f’
B:stu.age=20
stu.num=”40012120”
D:stu=”lili”
答案:B
2.
有以下程序段,输出结果为()。
#include <stdio.h>
struct s
{ int a;
char b;
double f;
};
main()
{ printf("%d",sizeof(struct s));
}
A:
13
B:12
C:24
D:16
3.有以下程序段,输出结果为()。
#include<stdio.h>
struct person
{char name[20];
int count;
}leader[3]={"Li",0,"Zhang",0,"Sun",0};
main()
{printf("%s",leader[1].name);
}
A:
Zhang
B:sun
C:0
D:Li
4.有以下程序段,输出结果为()。
#include<stdio.h>
struct student
{int num;
char name[20];
float score;
};
main()
{struct student stu[5];
printf("%d",sizeof(stu));
}
A:
160
B:随机值
C:5
D:140
5.以下程序段,在空白处填写()能使程序正确运行并输出结果。
#include<stdio.h>
struct student
{long num;
char name[10];
char sex;
float score;
};
main()
{struct student stu={10101,"lili",'m',89.5},*pt;
printf("%.2f",pt->score);
}
A:
*pt=stu;
pt=stu;
C:*pt=&stu;
D:pt=&stu;
6.有结构体声明如下,成员next是一个指针,指向对象的类型是()。
struct node
{
char ch;
struct node *next;
};
A:
int
float
C:char
D:node
7.有以下共用体声明,赋值错误的是()。
union data
{
int i;
char ch;
float f;
}
A:
union data a;a.i=97;
union data a={97};
C:union data a={97,'b',1.5};
D:union data a;a.i=’a’;
8.以下程序段的运行结果为()。
#include<stdio.h>
union data
{
int i;
char ch;
float f;
};
main()
{union data a;
a.i=98;
a.ch='B';
printf("%d",a.i);
}
A:
98
B:66
C:随机值
D:0
9.有枚举定义enum sex{m,f} stu;能够正确赋值的是()。
A:stu=f B:stu=nan C:stu={m,f} D:stu=man 10.
有新类型名声明typedef int Num[10];以下各项中与int a[10]含义相同的是()。
A:
Num a[10]
typedef a[10]
C:Num a
D:typedef a