Suppose STACK is allocated N=6 memory cells and initially STACK is empty, or, in other words, TOP = 0.find the output of the following module:
1. Set AAA:=3 and BBB:=5.
2. Call PUSH(STACK, AAA).
Call PUSH(STACK, 4).
Call PUSH(STACK, BBB+2).
Call PUSH(STACK, 8).
Call PUSH(STACK, AAA+BBB).
3. Repeat while TOP!=0;
Call POP(STACK, ITEM).
Write: ITEM.
[End of loop]
4. Return
Look carefully at the link from helios. He's giving you a big hint.
A Last In First Out (LIFO) stack is a lot like the plate dispenser you see at the start of a cafeteria food line. It gets PUSHed down when you add plates on and POPs up when you take one off.
So, Call PUSH(STACK, AAA) where AAA=3: Imagine writing the number 3 on a plate and PUSH it onto the STACK. The "3" plate is on TOP.
Then, Call PUSH(STACK, 4) : Now write the number 4 on another plate and PUSH it onto the STACK. The STACK drops down. The "4" plate is on TOP (of the "3" plate").
Continue adding plates BBB+2, 8, etc.
When you're done you have a STACK of plates where the last one you put on is on is at the top and a history of every plate you put on before it is stacked below.
To get the output of the pseudocode, POP a plate off, read the number on it, POP off the next, read it, etc. until there are no more plates (TOP=0).
You are simply undoing (POP) now what you did before (PUSH) but in reverse order.
Guys please help me to run this program i think i hae a problem on my formula.
using namespace std;
int highest(int x, int y, int z);
int main()
{
int x,y,z, sum, ave, highest;
cout<<"Enter first number: ";
cin>>x;
cout<<"Enter second number: ";
cin>>y;
cout<<"Enter third number: ";
cin>>z;
cout<<"\n\n\n";
cout << "The sum is: "<< sum << " ." << endl;
cout << "The average of is: " << ave << "." << endl;
cout << "The highest integer out of the 3 integers you typed is: "<< highest<<"\n";;