imaxdiv() in C++

imaxdiv(): This function is available in the file inttypes.h. This function computes the quotient and the remainder of two integer values of any size as a single operation. This function return Value imaxdiv called with arguments of type intmax_t returns a structure of type imaxdiv_t that comprises the quotient and the remainder.

Parameters: Two parameters are required for this function.

numer- The numerator. 

denom -The denominator.

Syntax:

imaxdiv(numer, denom)

For Example:

imaxdiv(10,3) = > The values returned as quot = 3 rem = 1

Approach

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    intmax_t numer = 10denom = 3;

    imaxdiv_t res = imaxdiv(numerdenom);

    cout << "quot = " << res.quot << " rem = " 
<< res.rem << "\n";

    return 0;
}


No comments:

Post a Comment