Mega Code Archive

 
Categories / C Tutorial / Stdlib h
 

Div

Item Value Header filestdlib.h Declarationdiv_t div(int numerator, int denominator); Returnreturns the quotient and the remainder of the operation numerator/denominator in a structure of type div_t. The structure type div_t has these two fields: int quot; /* quotient */   int rem;  /* remainder */ #include <stdlib.h>   #include <stdio.h>   int main(void)   {     div_t n;     n = div(10, 3);     printf("Quotient and remainder: %d %d.\n", n.quot, n.rem);     return 0;   } Quotient and remainder: 3 1.