The function ldiv () in C

The div_t div function (long int numer, long int denom) divides the numerator numer to denom.

The function ldiv () in C

The div_t div function (long int numer, long int denom) divides the numerator numer to denom .

The function ldiv () in C

Below is the declaration for ldiv () in C:

 div_t div ( long int numer , long int denom ) 

Parameters

numer : numerator.

denom : denominator.

Returns the value

This function returns the value in an internal, two-part structure, with div_t it is: long quot; long rem;

For example

The following C program illustrates the usage of ldiv () in C:

 #include #include int main () { ldiv_t output ; output = ldiv ( 100000L , 30000L ); printf ( "Phan thuong cua phep chia = %ldn" , output . quot ); printf ( "Phan du cua phep chia = %ldn" , output . rem ); return ( 0 ); } 

Compiling and running the above C program will result:

The function ldiv () in C Picture 1The function ldiv () in C Picture 1

According to Tutorialspoint

Previous lesson: Labs () function in C

Next lesson: The function rand () in C

5 ★ | 1 Vote