Div () function in C
Div () function in C
Div_t div function (int numer, int denom) divides numer numerator for denom .
Declare the div () function in C
Below is the declaration for div () in C:
div_t div ( int numer , 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: int quot; int rem;
For example
The following C program illustrates the usage of div () in C:
#include #include int main () { div_t output ; output = div ( 27 , 4 ); printf ( "Phan thuong cua phep chia (27/ 4) = %dn" , output . quot ); printf ( "Phan du cua phep chia (27/4) = %dn" , output . rem ); output = div ( 27 , 3 ); printf ( "nPhan thuong cua phep chia (27/ 3) = %dn" , output . quot ); printf ( "Phan du cua phep chia (27/3) = %dn" , output . rem ); return ( 0 ); }
Compiling and running the above C program will result:

According to Tutorialspoint
Previous lesson: Function abs () in C
Next lesson: Labs () function in C
Update 25 May 2019
You should read it
- Call the function by pointer in C ++
- Function realloc () in C
- Malloc () function in C
- Function abs () in C
- The function getenv () in C
- The function rand () in C
- The abort () function in C
- Pass cursor to function in C ++
- Cursor this in C ++
- Labs () function in C
- The function ldiv () in C
- The qsort () function in C
Maybe you are interested
Admire the rare and beautiful 'astronomical ring' of the universe Unbelievable coincidence in history makes the whole world astounded How to directly see the phenomenon of super moon, blue moon and eclipse converging after more than 150 years The most anticipated astronomical events of 2017 How terrible is the rocket that will bring people to Mars? Learn about extraterrestrial super-Earth - Gliese 581c