lldiv() function in C++ STL


lldiv() function in C++ STL gives the result of quotient and remainder of the division of the two numbers.

Algorithm

Begin
   Take two long type numbers as input.
   Call function lldiv().
   Print the quotient and remainder.
End.

Example Code

#include <cstdlib>
#include <iostream>
using namespace std;
int main() {
   long long q = 500LL;
   long long r = 25LL;
   lldiv_t res = lldiv(q, r);
   cout << "Quotient of " << q << "/" << r << " = " << res.quot << endl;
   cout << "Remainder of " << r << "/" << r << " = " << res.rem << endl;
   return 0;
}

Output

Quotient of 500/25 = 20
Remainder of 25/25 = 0

Updated on: 30-Jul-2019

85 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements