What is div() in c programming?

div in c programming performs division operation.

It is defined in stdlib.h header file.

Prototype

div_t div(int numerator,int denominator);

Return value

This function returns the structure containing quotient and remainder.


Example program for div()

// C program to illustrate div function
#include<stdlib.h>
#include<stdio.h>
int main()
{
  div_t res;
  res=div(100,56);
  printf("result is : quetiont=%d \t remainder=%d \n",res.quot,res.rem);
  return 0;
}

Read Stdlib.h GNU Manual

Output

div in c example

Code explanation

The division operation is performed using div() and result is being displayed.


People also ask for

What is div() in c?

div() performs division operation. It is defined in stdlib.h header file.