For problem two the structure is bit field structure
a:1 means only one lower order bit will be stored
b:2 means only two lower order bits will be stored
since both are defined as int (signed)

t.b = 6 means 110, but 10 will be stored to b and being signed
interger its value become -2
t.b = 7 means 111, but 11 will be stored to b and being signed
interger its value become -1


On Thu, Jul 14, 2011 at 9:11 AM, shilpa gupta <[email protected]> wrote:
> in second problem a:1 and b:3 means default initialization but not in c it
> is D programming language but u may b trying to compile it with c complier
> that's why it is showing wrong result..........if u will compile it with D
> language compiler than it will print 6 and 2.....and if u will not
> initialize them again with 6 and 2 then it will print 1 and 2
>
>
> On Thu, Jul 14, 2011 at 8:27 AM, John Hayes <[email protected]>
> wrote:
>>
>> Hey Guys, plz help me in getting these 2 C output problems
>>
>> 1st problem
>>
>> #include<stdio.h>
>> int main()
>> {
>> short int a,b,c;
>> scanf("%d%d",&a,&b);
>> c=a+b;
>> printf("%d",c);
>> return 0;
>> }
>> INPUT-
>> 1 1
>> OUTPUT
>> 1
>> i am not getting why  1 is coming in the output.....what difference is
>> using short making in the code ???
>> Problem No. 2
>> #include<stdio.h>
>> main()
>> {
>> struct
>> {
>> int a:1;
>> int b:2;
>> }t;
>> t.b=6;
>> t.a=2;
>> printf("%d %d",t.a,t.b);
>> }
>> OUTPUT
>> 0 -2
>> What does the statement  a:1 and b:1 mean and what are they doing.....i am
>> seeing them first time ever...hence not able to get the output....if someone
>> has any idea plz help  !!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>
>
>
> --
> shilpa gupta
> b tech 2nd year
> computer science and engineering
> mnnit allahabad
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Sanjay Ahuja,
Analyst, Financing Prime Brokerage
Nomura Securities India Pvt. Ltd

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to