Vidyalelo
C++ Programming · Q810

C++ miscellaneous

Programming · C++ Programming · question 810

Q810

What will be the output of the following C++ code? #include #include using namespace std; int main() Valarray varr = 10, 2, 20, 1, 30 ; for (int &x: varr) cout << x << " "; cout<<endl; varr = varr.apply([](int x)return x+=5;); for (int &x: varr) cout << x << " "; return 0;

A.
10 2 20 1 30
15 7 25 6 35
Answer
B.
10 2 20 1 30
10 7 25 6 35
C.
10 2 20 1 30
15 7 20 1 35
D.
15 7 25 6 35

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board