What will be the output of the following C++ code? [code] #include <iostream> #include <Valarray> using namespace std; int main() { Valarray<in

What will be the output of the following C++ code?
Code:
#include <iostream>
#include <Valarray>
using namespace std;
int main()
{
	Valarray<int> varr = { 1, 2, 3, 4, 5 };
	for (int &x: varr) cout << x << " ";
	cout<<endl;
	varr = varr.shift(2);
	for (int &#038;x: varr) cout << x << " ";
	return 0;
}
A.
1 2 3 4 5
3 4 5 0 0
B.
1 2 3 4 5
0 0 3 4 5
C.
1 2 3 4 5
1 2 3 4 5
D.
1 2 3 4 5
3 4 5 1 2
 

Ẽm Thư

New member
Answer: a
Explanation: In this program we are trying to shift elements of Valarray towards left by 2 using the shift() function of the complex header.
 

Tìm kiếm

Top