-
What is the output of this program?
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
vector<int> VectorData;
int add (0);
VectorData.push_back (50);
VectorData.push_back (150);
VectorData.push_back (200);
while (!VectorData.empty())
{
add += VectorData.back();
VectorData.pop_back();
}
cout << add << '\n';
return 0;
}
-
- 50
- 150
- 200
- 400
- None of these
Correct Option: D
In this program, We are forming a stack and adding the elements and We are finding the total number of elements that are in stack.