Sunday, 17 July 2011

To create a variable that takes only 3 bits memory

CODE:
#include<stdio.h>
#include<conio.h>
struct abc

{
   unsigned xyz : 3; //takes 3 bit memory
}st;

void main()

{
   clrscr();
   st.xyz = 7; //(1112
   printf("\nValue of xyz(before increment) : %d",st.xyz);
   st.xyz++;
   printf("\nValue of xyz(after increment) : %d",st.xyz);
   getch();
}


OUTPUT:
Value of xyz(before increment) : 7
Value of xyz(after increment) : 0

No comments:

Post a Comment