This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Basics of Structures – 2”.
Pre-requisite for C Structure MCQ set: C Video Tutorial on Structures.
1. 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;
no = 8;
printf("%d", no);
}
a) Nothing
b) Compile time error
c) Junk
d) 8
View Answer
Explanation: None.
2. How many bytes in memory taken by the following C structure?
#include <stdio.h>
struct test
{
int k;
char c;
};
a) Multiple of integer size
b) integer size+character size
c) Depends on the platform
d) Multiple of word size
View Answer
Explanation: None.
3. What will be the output of the following C code?
#include <stdio.h>
struct
{
int k;
char c;
};
int main()
{
struct p;
p.k = 10;
printf("%d\n", p.k);
}
a) Compile time error
b) 10
c) Undefined behaviour
d) Segmentation fault
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
struct
{
int k;
char c;
} p;
int p = 10;
int main()
{
p.k = 10;
printf("%d %d\n", p.k, p);
}
a) Compile time error
b) 10 10
c) Depends on the standard
d) Depends on the compiler
View Answer
Explanation: None.
5. What will be the output of the following C code?
#include <stdio.h>
struct p
{
int k;
char c;
};
int p = 10;
int main()
{
struct p x;
x.k = 10;
printf("%d %d\n", x.k, p);
}
a) Compile time error
b) 10 10
c) Depends on the standard
d) Depends on the compiler
View Answer
Explanation: None.
6. What will be the output of the following C code?
#include <stdio.h>
struct p
{
int k;
char c;
float f;
};
int p = 10;
int main()
{
struct p x = {1, 97};
printf("%f %d\n", x.f, p);
}
a) Compile time error
b) 0.000000 10
c) Somegarbage value 10
d) 0 10
View Answer
Explanation: None.
7. What will be the output of the following C code according to C99 standard?
#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) 3.000000
b) Compile time error
c) Undefined behaviour
d) 1.000000
View Answer
Explanation: None.
8. What will be the output of the following C code according to C99 standard?
#include <stdio.h>
struct p
{
int k;
char c;
float f;
};
int main()
{
struct p x = {.c = 97, .k = 1, 3};
printf("%f \n", x.f);
}
a) 3.000000
b) 0.000000
c) Compile time error
d) Undefined behaviour
View Answer
Explanation: None.
9. What will be the output of the following C code according to C99 standard?
#include <stdio.h>
struct p
{
int k;
char c;
float f;
};
int main()
{
struct p x = {.c = 97};
printf("%f\n", x.f);
}
a) 0.000000
b) Somegarbagevalue
c) Compile time error
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.
- Watch Advanced C Programming Videos
- Check Computer Science Books
- Practice Computer Science MCQs
- Apply for Computer Science Internship
- Check C Books