It doesn't in both cases it outputs the correct number or rather the number you asked it to calculate.
Simple case first
40*numberOfStems/100 where numberOfStems = 100
40*100/100 = 40
The case that is probably confusing you
float lowMark=1/4;
You have chosen to store the result in a float (best practice is to use double rather than float unless you have an communicable reason why floats should be used) because you are expecting a fraction, that is good.
However you have written 1/4 both 1 and 4 are integers so it does integer arithmetic under integer arithmetic 1/4 = 0. Having calculated 0 it converts it to a float for storage.
You need to force it to do floating point arithmetic, the easiest way to do that is to use floating point constants rather than integer constants like this