C Reference function div()
This function of stdlib.h will return the quotient and remainder of the division of numerator by denominator integers n,d.
Usage of div():
div_t div ( int n, int d );
Parameters:
n = numerator
d = denominator
Return value:
Returns a structure with div_t.quot and div_t.rem
Source code example of div():
#include<stdio.h>
#include<stdlib.h>
int main ()
{
div_t div_res;
div_res = div (18,7);
printf ("18 div 7 = %d, remainder %d.\n", div_res.quot, div_res.rem);
return 0;
}
Output of the div example program above:
18 div 7 = 2 remainder 4
This entry was posted in C Reference stdlib.h Functions.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
Tweet This! or use
to share this post with others.