Numbers


  1. Which can be used to create a random number without duplication?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Time


  1. How many parameters are available in partial_sum function in c++?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    There are three or four parameters available in partial_sum function in C++. They are first and last element, result and an optional binary operator.



  1. What is the output of this program?
    #include <iostream>
    #include <functional>
    #include <numeric>
    using namespace std;
    int Accumulator (int n, int m)
    {
    return n - m;
    }
    int Product (int n, int m)
    {
    return n + m;
    }
    int main ()
    {
    int p = 150;
    int Array1[] = {12, 22, 33};
    int Array2[] = {11, 12, 13};
    cout << inner_product(Array1, Array1 + 3, Array2, p ,Accumulator,
    Product);
    cout << endl;
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    In this program, We are forming the custom function from two ranges by using inner_product function.


  1. What is the output of this program?
    #include <iostream>
    #include <functional>
    #include <numeric>
    using namespace std;
    int mnewfunction (int n, int m)
    {
    return n + 3 * m;
    }
    struct N
    {
    int operator()(int n, int m)
    {
    return n + 3 * m;
    }
    } structObject;
    int main ()
    {
    int a = 200;
    int Arr[] = {11, 21, 31};
    cout << accumulate (Arr, Arr + 3, a, minus<int>() );
    cout << endl;
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    In this program, We are finding the difference between the init and the total of numbers range.



  1. What is the output of this program?
     #include <iostream>
    #include <functional>
    #include <numeric>
    using namespace std;
    int myop (int p, int q)
    {
    return p + q + 1;
    }
    int main ()
    {
    int value[] = {11, 12, 13, 14, 15, 16};
    int Res[5];
    partial_sum (value, value + 5, Res);
    for (int k = 0; k < 6; k++)
    cout << Res[k] << ' ';
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    In this program, We are calculating the sum of the given range by using partial_sum function.