how this program of C works and what is the output


#include
void main()
{
struct value
{
int bit1:2;
int bit3:4;
int bit4:4;
}bit={1,2,13};
printf("%d %d %d\n",bit.bit1,bit.bit3,bit.bit4);
}

Replies

  • rahul69
    rahul69
    jasim92
    how this program of C works and what is the output
    The code given is an example of bit manipulation in C.
    The first element of the structure is assigned a space of 2 bits and next two are given 4 bits each.
    Since int is used (signed integers), the output will be 1,2,-3.
  • Jasim Chouhan
    Jasim Chouhan
    rahul69
    The code given is an example of bit manipulation in C.
    The first element of the structure is assigned a space of 2 bits and next two are given 4 bits each.
    Since int is used (signed integers), the output will be 1,2,-3.
    Thank you Rahul
  • dmankit
    dmankit
    The output of this code is:
    1 2 -3
    As int use signed integers, so 13 get converted into -3.

You are reading an archived discussion.

Related Posts

I am 2.5 yr of exp in IT sector as a developer in skill Microsoft Dynamic CRM 4.0 (MSCRM). m not good in coding.. every time i need someones help...
I've been curiously reading about the Laravel framework and most of the things look pretty impressive. I'm wondering if we have any php developers who've actively used Laravel for any...
Quote: Technology makes us curious, and the smartphone revolution has taken technological innovation to dizzying heights. Things like gesture interface, which we had all glimpsed in the Tom Cruise film...
Quote: Enroll to get: 7 lessons accessible anytime, anywhere Learn by doing with hours of project focused instruction Complete material lists and downloadable project resources One-on-One help with your questions...
In a bid to brighten up the world of Colorblind users, Microsoft has developed a novel Color Binoculars app. The new app, 9.4 MB in size makes use of the...