Calculation: divide and mod, / %
/* Calculation: divide and mod, / % */
#include <stdio.h>
void main()
{
int total = 45;
int divider = 7;
int a = 0;
int b = 0;
a = total/divider;
printf(" total is %d and divider is %d", total, divider);
printf("\n a is %d.", a);
/* left over */
b = total%divider;
printf("\nThere are %d left over.\n", b);
}
Related examples in the same category