Jasim Chouhan
Jasim Chouhan
Branch Unspecified
24 Nov 2016

how this program of C works and what is the output

<code>
#include<stdio.h>
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);
}
</code>
rahul69

rahul69

Branch Unspecified
2 years ago
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

Branch Unspecified
2 years ago
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

Branch Unspecified
2 years ago
The output of this code is:
1 2 -3
As int use signed integers, so 13 get converted into -3.

Share this content on your social channels -

Only logged in users can reply.