consider the following statements. stacktype stack; int x,y ; suppose that the i
ID: 3868224 • Letter: C
Question
consider the following statements.
stacktype stack;
int x,y ;
suppose that the input is
14 45 34 23 10 5 -999
Consider the following statements:
stackType<int> stack;
int x;
Suppose that the input is:
14 45 34 23 10 5 -999
Show what is output by the following segment of code:
stack.push(5);
cin >> x;
while (x != -999)
{
if (x % 3 == 0)
{
if (!stack.isFullStack())
stack.push(x);
}
else
cout << "x = " << x << endl;
cin >> x;
}
cout << "Stack Elements: ";
while (!stack.isEmptyStack())
{
cout << " " << stack.top();
stack.pop();
}
cout << endl;
Explanation / Answer
14%3 == 0 is false
45%3 == 0 is true
34%3 == 0 is false
23%3 == 0 is false
10%3 == 0 is false
5%3== 0 is false
Ans 5 45
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.