This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Basics of Structures – 1”.
Pre-requisite for C Structure MCQ set: C Video Tutorial on Structures.
1. Which of the following are themselves a collection of different data types?
a) string
b) structures
c) char
d) all of the mentioned
View Answer
Explanation: None.
2. User-defined data type can be derived by___________
a) struct
b) enum
c) typedef
d) all of the mentioned
View Answer
Explanation: None.
3. Which operator connects the structure name to its member name?
a) –
b) <-
c) .
d) Both <- and .
View Answer
Explanation: None.
4. Which of the following cannot be a structure member?
a) Another structure
b) Function
c) Array
d) None of the mentioned
View Answer
Explanation: None.
5. Which of the following structure declaration will throw an error?
a)
struct temp{}s; main(){}
b)
struct temp{}; struct temp s; main(){}
c)
struct temp s; struct temp{}; main(){}
d) None of the mentioned
View Answer
Explanation: None.
6. What will be the output of the following C code?
#include <stdio.h>
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
View Answer
Explanation: None.
7. What will be the output of the following C code?
#include <stdio.h>
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
View Answer
Explanation: None.
8. What will be the output of the following C code?
#include <stdio.h>
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
View Answer
Explanation: None.
9. What will be the output of the following C code?
#include <stdio.h>
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
View Answer
Explanation: None.
10. Can the following C code be compiled successfully?
#include <stdio.h>
struct p
{
int k;
char c;
float f;
};
int main()
{
struct p x = {.c = 97, .f = 3, .k = 1};
printf("%f\n", x.f);
}
a) Yes
b) No
c) Depends on the standard
d) Depends on the platform
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – C Programming Language.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Watch Advanced C Programming Videos
- Apply for C Internship
- Check Computer Science Books
- Practice Computer Science MCQs
- Practice BCA MCQs