main()
{
int a=4,b=2;
a=b<<a + b>>2;
printf("%d", a);
}
Answers were Sorted based on User's Feedback
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 ? | 171 Yes | 6 No |
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 ? | 78 Yes | 10 No |
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 |
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 |
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 |
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 |
Answer / aravind
It shows syntax error because relational operators are used only for checking conditions.
Is This Answer Correct ? | 8 Yes | 23 No |
Write the test cases for checking a variable having value in range -10.0 to +10.0?
main() { int i,j,A; for(A=-1;A<=1;A++) prinf("%d\t",!!A); }
What is the sizeof () operator?
Why c is called a mid level programming language?
What are the advantages of union?
extern static int i func() { i =10; i++; printf("%d \n",i); } main() { i =20; printf("%d \n",i); func(); printf("%d \n",i); }
What is "Duff's Device"?
What are the preprocessors?
What is the difference between void main and main in c?
What is optimization in c?
int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above
What is the difference between text and binary modes?