The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 399 Weeks Ago, 2 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
. Show what is written by the following segments of code, given that item1, item2, and item3 are int variables.
a. StackType<int> stack;
item1 = 1;
item2 = 0;
item3 = 4;
stack.Push(item2);
stack.Push(item1);
stack.Push(item1 + item3);
stack.Pop(item2);
stack.Push(item3*item3);
stack.Push(item2);
stack.Push(3);
stack.Pop(item1);
cout << item1 << endl << item2 << endl << item3
<< endl;
while (!stack.IsEmpty())
{
stack.Pop(item1);
cout << item1 << endl;
}
b. StackType<int> stack;
item1 = 4;
item3 = 0;
item2 = item1 + 1;
stack.Push(item2);
stack.Push(item2 + 1);
stack.Push(item1);
stack.Pop(item2);
item1 = item2 + 1;
stack.Push(item1);
stack.Push(item3);
while (!stack.IsEmpty())
{
stack.Pop(item3);
cout << item3 << endl;
}
cout << item1 << endl << item2 << endl << item3 << endl;
Use the following information for Exercises 4–7. The stack is implemented as a class containing an array of items, a data member indicating the index of the last item put on the stack (top), and two Boolean data members, underFlow and overFlow. The stack items are characters and MAX_ITEM is 5. In each exercise, show the result of the operation on the stack. Put a T or F for true or false, respectively, in the Boolean data members.
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll