1.
while (there are more characters in the word to read)
{
read a character;
push the character on the stack;
}
If stack is full, then the value on the top of stack is last word which we push in the last of the loop.
Or we can say the last character of the stack will be on the top if the stack is full.
2.
while (the stack is not empty)
{
pop a character off the stack;
write the character to the screen;
}
If we are doing pop-up the values, then the output will of the program will be the opposite as just of insertion series.
Comments
Leave a comment