div
Calculates the quotient and remainder (function or macro)
#include <stdlib.h>
div_t div (
int number,
int denom);
div returns a structure of type div_t, which contains the fields quot and rem.
The div function or macro calculates the quotient and remainder of the division of the numerator numer by the denominator denom.
#include <stdlib.h>
#include <stdio.h>
void print_time (int seconds)
{
auto div_t min_sec;
min_sec = div (seconds, 60);
printf ("It took %d minutes and %d seconds\n",
min_sec.quot, min_sec.rem);
}
produces the following:
It took 2 minutes and 23 seconds