Structures, Unions, Enums

Q1: Bit fields CANNOT be used in union.

A True

B False

ANS:B - False

The following is the example program to explain "using bit fields inside an union".
#include<stdio.h>

union Point
{
  unsigned int x:4;
  unsigned int y:4;
  int res;
};

int main()
{
   union  Point pt;

   pt.x = 2;
   pt.y = 3;
   pt.res = pt.y;

   printf("\n The value of res = %d" , pt.res);

   return 0;
}
// Output: The value of res = 3



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.