main()
{
int a=4,b=2;
a=b<<a + b>>2;
printf("%d", a);
}

Answers were Sorted based on User's Feedback



main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }..

Answer / ram

Ans=32

Is This Answer Correct ?    273 Yes 22 No

main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }..

Answer / neha saxena

a=b<<a+b>>2
=2<<4+2>>2

According to precedence Table
1) + operated very 1st, (4+2=6)
2) then<< (left shift), (2<<6, 2 shifted left side 6 times
= 128)
3) and at last >> (right shift), (128>>2, 128 shifted right
side 2 times = 32)

Explanation in Answer No. 5, 6 & 7 are wrong

Is This Answer Correct ?    172 Yes 7 No

main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }..

Answer / satya

yes , the output will be 32....
<< and >> are bitwise operators... not relational ops..
reason:
<< means left shift operator..
>> means right shift operator..
for example.. if we give 2>>1
binary number for 2 is 0000 0010
the operator is right shift..so 0000 0001
for example.. if we give 2<<1
binary number for 2 is 0000 0010
the operator is left shift..so 0000 0100
go through this u will get the output...

Is This Answer Correct ?    79 Yes 10 No

main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }..

Answer / manish soni tagore collage jai

b<<a=2<<4=32;
and
b>>2=1>>2=0
so
32+0=32

Is This Answer Correct ?    47 Yes 5 No

main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }..

Answer / abhishek ranjan

32

Is This Answer Correct ?    37 Yes 3 No

main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }..

Answer / alamuru sreenivasa reddy

2<<4 that means 2 is left shifted by 4 times. then we will get 0010 0000=32 in decimal form. similarly 1>>2 means that is right shifted 2 times we will get 0000 0000=0.. so 0+32=32
i.e answer

Is This Answer Correct ?    24 Yes 10 No

main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }..

Answer / amalu

32

Is This Answer Correct ?    2 Yes 1 No

main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }..

Answer / vignya

size of integer is 8 bits
a=0000 0100, b=0000 0010;
b>>2 becomes 0000 0000 and b<<a becomes 0010 0000
on whole a= 0010 0000+ 0000 0000=0010 0000 =32

Is This Answer Correct ?    1 Yes 0 No

main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }..

Answer / sandeep kumar

Both shift operator has same precedence but associativity left to right so first calculate b>>2=0 then calculate b<<4=32 then add the both result

Is This Answer Correct ?    1 Yes 3 No

main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }..

Answer / aravind

It shows syntax error because relational operators are used only for checking conditions.

Is This Answer Correct ?    8 Yes 23 No

Post New Answer

More C Interview Questions

What is the Purpose of 'extern' keyword in a function declaration?

0 Answers  


Can we use any name in place of argv and argc as command line arguments?

0 Answers  


34.what are bitwise shift operators? 35.what are bit fields? What is the use of bit fields in a structure declaration? 36.what is the size of an integer variable? 37.what are the files which are automatically opened when a c file is executed? 38.what is the little endian and big endian? 39.what is the use of fflush() function? 40.what is the difference between exit() and _exit() functions? 41.where does malloc() function get the memory? 42.what is the difference between malloc() and calloc() function? 43.what is the difference between postfix and prefix unary increment operators?

3 Answers  


User define function contain thier own address or not.

2 Answers  


what are non standard function in c

0 Answers  






what is diognisis?

1 Answers  


What is property type c?

0 Answers  


what will be the output of" printf("%d%d",scanf("%d% d",&a&b));"

4 Answers  


How many bytes are occupied by near, far and huge pointers (dos)?

0 Answers  


how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions

0 Answers  


Write a program to accept a character & display its corrosponding ASCII value & vice versa?

9 Answers  


C passes By value or By reference?

5 Answers   Geometric Software, Infosys,


Categories