Here is a listing of C programming questions on “Sizeof” along with answers, explanations and/or solutions:
1. What is the sizeof(char) in a 32-bit C compiler?
a) 1 bit
b) 2 bits
c) 1 Byte
d) 2 Bytes
Answer: c
Clarification: None.
2. What will be the output of the following C code?
#includeprintf("%d", sizeof('a'));
a) 1
b) 2
c) 4
d) None of the mentioned
Answer: c
Clarification: None.
3. Size of an array can be evaluated by __________
(Assuming array declaration int a[10];)
a) sizeof(a);
b) sizeof(*a);
c) sizeof(a[10]);
d) 10 * sizeof(a);
Answer: a
Clarification: None.
4. What will be the output of the following C code?
-
#include
-
union temp
-
{
-
char a;
-
char b;
-
int c;
-
}t;
-
int main()
-
{
-
printf("%d", sizeof(t));
-
return 0;
-
}
a) 1
b) 2
c) 4
d) 6
Answer: c
Clarification: None.
5. Which of the following is not an operator in C?
a) ,
b) sizeof()
c) ~
d) None of the mentioned
Answer: d
Clarification: None.
6. Which among the following has the highest precedence?
a) &
b) <<
c) sizeof()
d) &&
Answer: c
Clarification: None.
7. What is the sizeof(void) in a 32-bit C?
a) 0
b) 1
c) 2
d) 4
Answer: b
Clarification: None.
8. What type of value does sizeof return?
a) char
b) short
c) unsigned int
d) long
Answer: c
Clarification: None.