VOOZH about

URL: https://www.geeksforgeeks.org/cpp/lldiv-function-in-c-stl/

⇱ lldiv() function in C++ STL - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

lldiv() function in C++ STL

Last Updated : 18 Jul, 2018
The lldiv() is a builtin function in C++ STL which gives us the quotient and remainder of the division of two numbers. Syntax:
lldiv(n, d)
Parameters: The function accepts two mandatory parameters which are described below:
  • n: It specifies the dividend. The data-type can be long long or long long int.
  • d: It specifies the divisor. The data-type can be long long or long long int.
Return value: The function returns a structure of type lldiv_t which consists of two members: quot and rem, where quot is the quotient and rem is the remainder. The struct is defined as follows:
struct lldiv_t {
 long long quot;
 long long rem;
};
Below programs illustrate the above function: Program 1:
Output:
Quotient of 1000/50 = 20
Remainder of 1000/50 = 0
Program 2:
Output:
Quotient of 251987/68 = 3705
Remainder of 251987/68 = 47
Comment
Article Tags: