I am doing some stack exercises and just want to make sure I havethe correct ans
ID: 3618900 • Letter: I
Question
I am doing some stack exercises and just want to make sure I havethe correct answers. Assume StackType is sent to int andSTACK_CAPACITY is set to 5. Give the values of myTop and thecontents of the array referred to by myArray in the stack s afterthe code segment is executed or indictate why an error occurs.1.
Stack s;
s.push(10);
s.push(22);
s.push(37);
s.pop();
s.pop();
This answer I put 10[0]
2.
Stack s;
s.push(10);
s.push(9);
s.push(8);
while(!s.empty())
s.pop();
This answer I put cannot be done because it goes empty and thenremoves a s.pop
3.
Stack s;
for (int i = 1; i <= 6; i++)
s.push(10*i);
Cannot be done because I is multiplied by 10 and the highest it canbe is 6
4.
Stack s;
s.push(11);
i = s.top();
s.pop();
This answer I put 3[0]
If these are wrong can someone explain to me what I need to put inhere