Numbers
- What is the output of this program?
#include <iostream>
#include <functional>
#include <numeric>
using namespace std;
int Function (int p, int q)
{
return p + 2 * q;
}
struct ClassN
{
int operator()(int p, int q)
{
return p + 3 * q;
}
} object;
int main ()
{
int num = 110;
int Array[] = {12, 25, 53};
cout << accumulate(Array, Array + 3, num);
cout << endl;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
In this program, We are calculating the product of every number in the given range by using accumulate function.
- 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;
}
int main ()
{
int value[] = {11, 12, 13, 15, 17};
int Res[5];
adjacent_difference (value, value + 7, Res);
for (int k = 0; k < 5; k++)
cout << Res[k] <<' ';
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
In this program, We are calculating the adjacent difference of the given range by using function adjacent_difference.
- What is the use of accumulate function in numeric library?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Returns the result of accumulating all the values in the range from first to last.
- Which mathematics library is used for vector manipulation in c++?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Blitz++ is a high-performance vector mathematics library written in C++.
- Which header file is used to operate on numeric sequences?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
header file is used to operate on numeric sequences that support certain operations.