My Report

C Structure and Union Test – 4


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. In the following declaration of bit-fields, the constant-expression specifies __________

    struct-declarator:
    declarator
    type-specifier declarator opt : constant-expression
    

2. Which of the following reduces the size of a structure?

3. Which of the following is not allowed?

4. In the following declaration of bit-fields, the constant-expression must be __________

    struct-declarator:
    declarator
    type-specifier declarator opt : constant-expression

5. Which of the following data types are accepted while declaring bit-fields?

6. What is the order for the following C declarations?

    short a : 17;
    int long y : 33;

7. For what minimum value of x in a 32-bit Linux OS would make the size of s equal to 8 bytes?

    struct temp
    {
        int a : 13;
        int b : 8;
        int c : x;
    }s;

8. What is the correct syntax to initialize bit-fields in an structure?

9. Calculate the % of memory saved when bit-fields are used for the following C structure as compared to with-out use of bit-fields for the same structure? (Assuming size of int = 4)

    struct temp
    {
        int a : 1;
        int b : 2;
        int c : 4;
        int d : 4;
    }s; 

10. Bit fields can only be declared as part of a structure.


 

Start practicing “1000 MCQs on C”, and once you are ready, you can take tests on all topics by attempting our “C Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.