-
What is the output of this program?
#include <iostream>
#include <queue>
using namespace std;
int main ()
{
queue<int> QueueData;
int add (0);
for (int k = 1; k <= 50; k++)
QueueData.push(k);
while (!QueueData.empty())
{
add += QueueData.front();
QueueData.pop();
}
cout << add << endl;
return 0;
}
-
- 75
- 1275
- 12
- Compilation Error
- None of these
Correct Option: B
In this program, We used the push and pop operation of quueue to find out the total of all the number from 1 to 50.