Programming Languages
C
Objective
Mar 08, 2013
What will be output of the following c code?
void main()
{
int i=3;
if(3==i)
printf("%d",i<<2<<1);
else
printf("Not equal");
}
Detailed Explanation
Associative of bitwise left shifting operator is left to right. In the following expression:
i<<2<<1
There are two bitwise operators. From rule of associative leftmost operator will execute first.
i <<><<>
After execution of leftmost bitwise left shifting operator:
so i=i*pow(2,2)
=3*
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts