p << = 2 ====> p = p << 2
but you written, p << 2 ===> it is stored in temporary variables in stack.
∴ you didn't modify the p, it will give it's initial value only.
approaches 1 :-
if you assign the final value to some variable and print it, then it is 20.
#include<stdio.h>
int main()
{
int p=10;
int t = p<<2>>1;
printf("%d",t);
return 0;
}
approaches 2 :-
#include<stdio.h>
int main()
{
int p=10;
int t = ;
printf("%d",p<<2>>1 );
return 0;
}
approaches 3 :- ( In this case, the value of p is updated, in approach 1 and approach 2 value of p doesn't update. )
#include<stdio.h>
int main()
{
int p=10;
p<<=2>>1;
printf("%d",t);
return 0;
}
But Note that the execution of the p <<= 2 >> 1 statement is like
p = p << ( 2 >> 1)
which is equivalent to p = ( p << 2 ) >> 1.