imag() in C++

imag(): This function is available in the file complex. This function returns the imaginary part of the complex number. It takes one argument as a complex number.

Parameters: One parameter is required for this function.

__X: The complex number whose imaginary part is to be determined.

Syntax:

imag(__X)

For Example:

complexNum (12,10)

imag(complexNum) = > It returns 10.

Approach

C++

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

int main()
{
    complex<double> complexNum(12, 10);

    cout << imag(complexNum) << "\n";

    return 0;
}

ilogbl() in C++

ilogbl(): This function is available in the file math.h. This function extracts the value of the unbiased exponent from the floating-point argument arg, and returns it as a signed integer value.

Parameters: One parameter is required for this function.

arg: The floating-point value.

Syntax:

ilogbl(arg)

For Example:

ilogbl(1000.25) = > It returns 9.

i

Approach

C++

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

int main()
{
    long double x = 1000.25;

    cout << ilogbl(x) << "\n";

    return 0;
}


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 = 10, denom = 3;

    imaxdiv_t res = imaxdiv(numer, denom);

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

    return 0;
}


inner_product() in C++

inner_product(): This function is available in the file stl_numeric.h. This function computes the inner product of two ranges. Starting with an initial value of __init. 

Multiplies successive elements from the two ranges and adds each product into the accumulated value using operator+(). The values in the ranges are processed in the order. It returns the final inner product.

Parameters:

 __first1 – Start of range 1. 

__last1 – End of range 1. 

__first2 – Start of range 2.

 __init – Starting value to add other values to it.

Syntax:

inner_product(__first1, __last1, __first2, __init)

For Example:

arr = {1, 2, 3, 10}, vec = {4, 5, 6, 45, 10}

inner_product(arr.begin(), arr.end(), vec.begin(),0) => It return the value 482.

1*4 + 2*5 + 3*6 + 10*45 =  482

Approach

C++

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

int main()
{
    vector<int> arr = {1, 2, 3, 10};
    vector<int> vec = {4, 5, 6, 45, 10};

    cout << inner_product(arr.begin(), arr.end(), 
vec.begin(), 0) << "\n";

    return 0;
}