Currently At: Programming Reference > C Reference > Standard C Math > div()

div()


Syntax:
#include <stdlib.h>
div_t div( int numerator, int denominator );


Description:
The function div() returns the quotient and remainder of the operation numerator / denominator. The div_t structure is defined in stdlib.h, and has at least:

int quot; // The quotient
int rem; // The remainder


Example:
div_t temp;
temp = div( x, y );
printf( "%d divided by %d yields %d with a remainder of %d\n", x, y, temp.quot, temp.rem );

OUTPUT: Quotient and remainder of x/y


Related Topics:
ldiv()


Web Standards & Support:

Link to and support eLook.org Powered by LoadedWeb Web Hosting
Valid XHTML 1.0! Valid CSS! eLook.org FireFox Extensions