Tuyết Trinh Nguyễn
New member
What will be the output of the following C++ code?
A. 100
B. 140
C. 160
D. 180
Code:
#include <iostream>
#include <functional>
#include <numeric>
using namespace std;
int myfunction (int x, int y)
{
return x + 2 * y;
}
struct myclass
{
int operator()(int x, int y)
{
return x + 3 * y;
}
} myobject;
int main ()
{
int init = 100;
int numbers[] = {10, 20, 30};
cout << accumulate(numbers, numbers + 3, init);
cout << endl;
}
B. 140
C. 160
D. 180