C Programming Questions and Answers – Sizeof Keyword – 1

«
»

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Sizeof Keyword – 1”.

Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.

advertisement

1. What is the sizeof(char) in a 32-bit C compiler?
a) 1 bit
b) 2 bits
c) 1 Byte
d) 2 Bytes
View Answer

Answer: c
Explanation: None.

2. What will be the output of the following C code?

advertisement
advertisement
    #include <stdio.h>
    printf("%d", sizeof('a'));

a) 1
b) 2
c) 4
d) None of the mentioned
View Answer

Answer: c
Explanation: None.
advertisement

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);
View Answer

Answer: a
Explanation: None.
advertisement

4. What will be the output of the following C code?

  1.     #include <stdio.h>
  2.     union temp
  3.     {
  4.         char a;
  5.         char b;
  6.         int c;
  7.     }t;
  8.     int main()
  9.     {
  10.         printf("%d", sizeof(t));
  11.         return 0;
  12.     }

a) 1
b) 2
c) 4
d) 6
View Answer

Answer: c
Explanation: None.
advertisement

5. Which of the following is not an operator in C?
a) ,
b) sizeof()
c) ~
d) None of the mentioned
View Answer

Answer: d
Explanation: None.

6. Which among the following has the highest precedence?
a) &
b) <<
c) sizeof()
d) &&
View Answer

Answer: c
Explanation: None.

7. What is the sizeof(void) in a 32-bit C?
a) 0
b) 1
c) 2
d) 4
View Answer

Answer: b
Explanation: None.

8. What type of value does sizeof return?
a) char
b) short
c) unsigned int
d) long
View Answer

Answer: c
Explanation: None.

Sanfoundry Global Education & Learning Series – C Programming Language.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement

Leave a Comment

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter

Check his free tutorial videos on Advanced C Programming. Join his Sanfoundry-Classes telegram channel for all videos and queries on Programming, Data-Structures, Kernel, Personality development and Mentoring.