lldiv() function in C++ STL Last Updated : 18 Jul, 2018 Comments Improve Suggest changes Like Article Like Report 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: CPP // C++ program to illustrate the // lldiv() function #include <cstdlib> #include <iostream> using namespace std; int main() { long long n = 1000LL; long long d = 50LL; lldiv_t result = lldiv(n, d); cout << "Quotient of " << n << "/" << d << " = " << result.quot << endl; cout << "Remainder of " << n << "/" << d << " = " << result.rem << endl; return 0; } Output: Quotient of 1000/50 = 20 Remainder of 1000/50 = 0 Program 2: CPP // C++ program to illustrate // the lldiv() function #include <cstdlib> #include <iostream> using namespace std; int main() { long long int n = 251987LL; long long int d = 68LL; lldiv_t result = lldiv(n, d); cout << "Quotient of " << n << "/" << d << " = " << result.quot << endl; cout << "Remainder of " << n << "/" << d << " = " << result.rem << endl; return 0; } Output: Quotient of 251987/68 = 3705 Remainder of 251987/68 = 47 Create Quiz Comment I IshwarGupta Follow 0 Improve I IshwarGupta Follow 0 Improve Article Tags : Misc C++ STL CPP-Functions cpp-math +1 More Explore C++ BasicsIntroduction to C++3 min readData Types in C++6 min readVariables in C++4 min readOperators in C++9 min readBasic Input / Output in C++3 min readControl flow statements in Programming15+ min readLoops in C++7 min readFunctions in C++8 min readArrays in C++8 min readCore ConceptsPointers and References in C++5 min readnew and delete Operators in C++ For Dynamic Memory5 min readTemplates in C++8 min readStructures, Unions and Enumerations in C++3 min readException Handling in C++12 min readFile Handling in C++8 min readMultithreading in C++8 min readNamespace in C++5 min readOOP in C++Object Oriented Programming in C++8 min readInheritance in C++6 min readPolymorphism in C++5 min readEncapsulation in C++3 min readAbstraction in C++4 min readStandard Template Library(STL)Standard Template Library (STL) in C++3 min readContainers in C++ STL2 min readIterators in C++ STL10 min readC++ STL Algorithm Library3 min readPractice & ProblemsC++ Interview Questions and Answers1 min readC++ Programming Examples4 min read Like