div function in C to find the quotient and reminder

While performin the division operation in a C program, we can get the reminted of division using the modulus operator. But getting quotient when the numbers are not completely divisble , for example if we divide 15 by 4, and want to find the quotient the usual divide operator will not be useful as it will give a floating point result. We can use the div function for this which is a part of the stdlib library. The div function takes two arguments, first one being the divident, the second one being the divisor.

The return value of the div fundtion is a structure of the form div_t, which has two member variables , Quotient and reminder.Thus to get the quotient and reminder we just ned to access these member variables in the return value of div.

Here is a example program.