self doubt
[closed]

in Programming closed by
203 views
0 votes
0 votes
closed with the note: got the answer.

consider

  1. temp=1;
  2. temp+=temp*temp<<2+3;
  3. printf(“%d”,temp); // this line will print output as $33$ how??

Line number 2 can be written as: temp=temp+temp*temp<<2+3;

my doubt is: *>+>» is the order of execution according to precedence rule;

now temp= 1+1*1<<2+3;

temp=1+1<<2+3

how $33$ will come?? please someone explain this??

in Programming closed by
203 views

1 comment

If Line 2 is written as “temp=temp+temp*temp<<2+3;”

Then change the order of precedence because we evaluate first “+” and then “<<

If Line 2 is written as “temp+= temp*temp<<2+3;”

we evaluate first “<<” and then “+=

 

ex: temp = 1

If line 2 is written as temp=temp+temp*temp<<2+3;

temp = 1 + 1 * 1<<2 + 3

temp = 1 + 1<<2 + 3

temp = 2 <<5

temp = 64

 

If line 2 is written as temp+= temp*temp<<2+3;

temp += 1 * 1<<2+3

temp += 1 <<2+3

temp += 1<<5

temp += 32

temp = 33

5
5

Related questions