+ 1
How i am getting this output ?
int a = 3; int b = ((++a) * (++a)); cout<< b; output :- 25 . How ????
9 Answers
+ 2
If ++ is before variable, it at first increments all variables, and then it counts arithmetic operations. It means (++a) * (++a) = (++3) * (++3) = (4) * (++4)= (5) * (5) = 25.
+ 2
But this gives the answer as 80 .
int a = 2;
int b = ((++a) * (++a) * (++a));
cout<< b;
output :- 80.
if we apply your logic ,
then it would look like this ,
It means (++a) * (++a) *(++a)= (++2) * (++2)*(++2) = (3) * (++3)*(++3).
(4)*(4)*(++4)
(5)*(5)*(5) =125
+ 2
but i am getting 80 for a = 2 .
+ 1
This logic fails here...
(++a)*(++a)=(++3)*(++3)=
=(4)*(++4)=
=(4)*(5)= 20
+ 1
someone help please
+ 1
explaination by vitali is correct
output of a=2; (++a)*(++a)*(++a); is 125
+ 1
Bro... Output depends from compiler to compiler.. some will say 20 some 25.. so its difficult to predict..
+ 1
ok.. i got it now.. Thanks everyone
0
For a=2.. (++a)*(++a)*(++a).. I'm getting 60
. so no one say anything