case 1:
(On*100)/Whole = (42*100)/100 = 4200/100 = 42
case 2:
(On/Whole)*100 = (42/100)*100 = 0*100 = 0
You are not using float variables and the intigers are not capable of holding floating point values. No approximation takes place. All the floating points are going bye bye. Even if the result was 0.999999, you would get 0 as well. This is how C works.
Percent = (On / Whole)*100;
First (On/Whole) is evaluated. Since all elements and result are integer, result of division is rounded 42/100=>0 and 0*100=0
In firs case On*100=42*100=4200 and 4200/100 =42
Therefore Temp = Percent = 0, such is the case with integer math. Of course if either the variable "On" or "Whole" were floating point, then the result would be: