I am just wondering, if I want to divide a by b, and am interested both in the result c and the remainder (e.g. say I have number of seconds and want to split that into minu
All else being equal, the best solution is one that clearly expresses your intent. So:
int totalSeconds = 453;
int minutes = totalSeconds / 60;
int remainingSeconds = totalSeconds % 60;
is probably the best of the three options you presented. As noted in other answers however, the div
method will calculate both values for you at once.