Div () function in C

Div_t div function (int numer, int denom) divides numer numerator for denom.

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:

Picture 1 of Div () function in C

According to Tutorialspoint

Previous lesson: Function abs () in C

Next lesson: Labs () function in C

Update 25 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile