Here is a listing of online C quiz on “Basics of Structures” along with answers, explanations and/or solutions:
1. Which of the following are themselves a collection of different data types?
a) string
b) structures
c) char
d) all of the mentioned
Answer: b
Clarification: None.
2. User-defined data type can be derived by___________
a) struct
b) enum
c) typedef
d) all of the mentioned
Answer: d
Clarification: None.
3. Which operator connects the structure name to its member name?
a) –
b) <-
c) .
d) Both <- and .
Answer: c
Clarification: None.
4. Which of the following cannot be a structure member?
a) Another structure
b) Function
c) Array
d) None of the mentioned
Answer: b
Clarification: None.
5. Which of the following structure declaration will throw an error?
a)
b)
struct temp{}; struct temp s; main(){}
c)
struct temp s; struct temp{}; main(){}
d) None of the mentioned
Answer: d
Clarification: None.
6. What will be the output of the following C code?
-
#include
-
struct student
-
{
-
int no;
-
char name[20];
-
}
-
void main()
-
{
-
struct student s;
-
s.no = 8;
-
printf("hello");
-
}
a) Compile time error
b) Nothing
c) hello
d) Varies
Answer: a
Clarification: None.
7. What will be the output of the following C code?
-
#include
-
struct student
-
{
-
int no = 5;
-
char name[20];
-
};
-
void main()
-
{
-
struct student s;
-
s.no = 8;
-
printf("hello");
-
}
a) Nothing
b) Compile time error
c) hello
d) Varies
Answer: b
Clarification: None.
8. What will be the output of the following C code?
-
#include
-
struct student
-
{
-
int no;
-
char name[20];
-
};
-
void main()
-
{
-
student s;
-
s.no = 8;
-
printf("hello");
-
}
a) Nothing
b) hello
c) Compile time error
d) Varies
Answer: c
Clarification: None.
9. What will be the output of the following C code?
-
#include
-
void main()
-
{
-
struct student
-
{
-
int no;
-
char name[20];
-
};
-
struct student s;
-
s.no = 8;
-
printf("%d", s.no);
-
}
a) Nothing
b) Compile time error
c) Junk
d) 8
Answer: d
Clarification: None.
10. Can the following C code be compiled successfully?
-
#include
-
struct p
-
{
-
int k;
-
char c;
-
float f;
-
};
-
int main()
-
{
-
struct p x = {.c = 97, .f = 3, .k = 1};
-
printf("%fn", x.f);
-
}
a) Yes
b) No
c) Depends on the standard
d) Depends on the platform
Answer: c
Clarification: None.