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 );


n = numerator

d = denominator

Return value:

Returns a structure with div_t.quot and div_t.rem

Source code example of div():


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. Both comments and pings are currently closed. Tweet This! Tweet This! or use to share this post with others.

Comments are closed.