This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Self-Referential Structures – 1”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. What will be the output of the following C code?
#include <stdio.h>
struct student
{
char *c;
struct student *point;
};
void main()
{
struct student s;
struct student m;
s.c = m.c = "hi";
m.point = &s;
(m.point)->c = "hey";
printf("%s\t%s\t", s.c, m.c);
}
a) hey hi
b) hi hey
c) Run time error
d) hey hey
View Answer
Explanation: None.
2. What will be the output of the following C code?
#include <stdio.h>
struct student
{
char *c;
struct student *point;
};
void main()
{
struct student s;
struct student m;
m.point = s;
(m.point)->c = "hey";
printf("%s", s.c);
}
a) Nothing
b) Compile time error
c) hey
d) Varies
View Answer
Explanation: None.
3. What will be the output of the following C code?
#include <stdio.h>
struct student
{
char *c;
struct student point;
};
void main()
{
struct student s;
s.c = "hello";
printf("%s", s.c);
}
a) hello
b) Nothing
c) Varies
d) Compile time error
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
struct student
{
char *c;
struct student *point;
};
void main()
{
struct student s;
printf("%d", sizeof(s));
}
a) 5
b) 9
c) 8
d) 16
View Answer
Explanation: None.
5. What will be the output of the following C code?
#include <stdio.h>
struct student
{
char *c;
struct student *point;
};
void main()
{
struct student s;
struct student *m = &s;
printf("%d", sizeof(student));
}
a) Compile time error
b) 8
c) 5
d) 16
View Answer
Explanation: None.
6. What will be the output of the following C code?
#include <stdio.h>
struct p
{
int x;
char y;
struct p *ptr;
};
int main()
{
struct p p = {1, 2, &p};
printf("%d\n", p.ptr->x);
return 0;
}
a) Compile time error
b) Undefined behaviour
c) 1
d) 2
View Answer
Explanation: None.
7. What will be the output of the following C code?
#include <stdio.h>
typedef struct p *q;
struct p
{
int x;
char y;
q ptr;
};
int main()
{
struct p p = {1, 2, &p};
printf("%d\n", p.ptr->x);
return 0;
}
a) Compile time error
b) 1
c) Undefined behaviour
d) Address of p
View Answer
Explanation: None.
8. Presence of loop in a linked list can be tested by ________
a) Traveling the list, if NULL is encountered no loop exists
b) Comparing the address of nodes by address of every other node
c) Comparing the the value stored in a node by a value in every other node
d) None of the mentioned
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.
- Check C Books
- Apply for C Internship
- Watch Advanced C Programming Videos
- Practice BCA MCQs
- Apply for Computer Science Internship