It will, but do not overuse comma operator (this can lead to unexpected behavior here), you even doesn't need an elseif actually:
1 2 3 4 5 6 7 8
if (hours <= 40) {
gross = hours * payrate;
ovthours = 0;
} else { //You do not need a condition (if hours not less or equal than 40, it will guaranteed larger than 40)
ovthours = hours - 40;
gross = 40 * payrate + 1.5 * payrate * (ovthours);
hours = 40;
}