div

Overview :

The "div" divides 2 integers and return both remainder and quotient as a div_t type which is a structure.

Syntax :
div_t div(int x,int y);
Description :

The "div" function accepts 2 parameters

  • x,y -> The x and y are the 2 numbers to be divided(x/y).


  • The function returns both remainder and quotient.



Example :
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>

int main()
{
  div_t ans;
  int x,y;
  clrscr();
  
  printf("\nEnter the value of x and y (x/y) : ");
  scanf("%d%d",&x,&y);
  
  ans = div(x,y);
  
  printf("Remainder is : %d\nQuotient is : %d\n",ans.rem,ans.quot);
  
  getch();
  return 0;
}

Comments

comments powered by Disqus