This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Sizeof Keyword – 2”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. Which among the following is never possible in C when members are different in a structure and union?
//Let P be a structure //Let Q be a union
a) sizeof(P) is greater than sizeof(Q)
b) sizeof(P) is less than sizeof(Q)
c) sizeof(P) is equal to sizeof(Q)
d) none of the mentioned
View Answer
Explanation: None.
2. Which among the following is never possible in C when members in a structure are the same as that in a union?
//Let P be a structure //Let Q be a union
a) sizeof(P) is greater than sizeof(Q)
b) sizeof(P) is equal to sizeof(Q)
c) sizeof(P) is less than to sizeof(Q)
d) none of the mentioned
View Answer
Explanation: None.
3. What will be the size of the following C structure?
#include <stdio.h>
struct temp
{
int a[10];
char p;
};
a) 5
b) 11
c) 41
d) 44
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
main()
{
int a = 1;
printf("size of a is %d, ", sizeof(++a));
printf("value of a is %d", a);
};
a) size of a is 4, value of a is 1
b) size of a is 4, value of a is 2
c) size of a is 2, value of a is 2
d) size of a is 2, value of a is 2
View Answer
Explanation: None.
5. Which among the following statement is right?
a) sizeof(struct stemp*) > sizeof(union utemp*) > sizeof(char *)
b) sizeof(struct stemp*) < sizeof(union utemp*) < sizeof(char *)
c) sizeof(struct stemp*) = sizeof(union utemp*) = sizeof(char *)
d) the order Depends on the compiler
View Answer
Explanation: None.
6. What will be the output of the following C code?
#include <stdio.h>
printf("%d", sizeof(strlen("HELLOWORLD")));
a) Output, 4
b) Output, 10
c) Output, 16
d) Error, sizeof cannot evaluate size of a function
View Answer
Explanation: None.
7. Which of the following cannot be used inside sizeof?
a) pointers
b) functions
c) macro definition
d) none of the mentioned
View Answer
Explanation: None.
8. What will be the output of the following C code?
#include <stdio.h>
(sizeof double = 8, float = 4, void = 1)
#define PI 3.14
int main()
{
printf("%d", sizeof(PI));
}
a) Output is 8
b) Output is 4
c) Output is 1
d) Error, we can’t use sizeof on macro-definitions
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.
- Apply for Computer Science Internship
- Check C Books
- Check Computer Science Books
- Practice BCA MCQs
- Apply for C Internship