+ 3
Explain this code
Int a=42; a*=a; a/=a; Printf("%d",a); Out put is 1
4 Answers
+ 6
a*=a means a= a*a so
a= 42*42= 1764 and similarly
a/=a means a= a/a so
a= 1764/1764= 1
+ 3
Edit your code a bit to add verbosity of the process. Hopefully this helps clear your doubt.
int a = 42;
printf("%d *= %d becomes ", a, a);
a *= a;
printf("%d\n", a);
printf("%d /= %d becomes ", a, a);
a /= a;
printf("%d\n", a);
+ 2
int a=42;
a*= a; /* This means a= a*a, means a=42*42 means a = 1764. Here 1764 will be stored in variable a */
a/= a; /* Here it means a= a/a that means a= 1764 /1764 that was stored in 'a' in previous line , then 'a' become 1 here and 1 will be stored in variable 'a' */
printf("%d ",a); /*Here the value of 'a' that is 1 will be printed that we got in previous line of the code */