What do you mean by stack program?
Get me an example stack program?
Answer Posted / puneettan
A Stack can be imagined as dinner plates put one over the
another.
'Push' means-- Inserting a new value(like putting a new
dinner plate on the top of the stack)
'Pop' means-- Removing(deleting) a value from the stack(just
like we remove a plate from the top of the stack)
A Stack follows L.I.F.O(Last In First Out).. This means, the
value which was last inserted into a stack would be the
first one to be removed. In the analogous case of dinner
plates, imagine that the plate kept last, on the top of
other plates will have to be removed first. you cannot
remove a plate at the bottom directly.
<--Program, same as given in 1st answer-->
//declaring the variables
char stack[10]
int top=-1;
//making a function for 'Push' mechanism
void push(char d)
{
if(to==9)
printf("stack is full");
else
stack[++top]=d;
}
//making a function for 'Pop' mechanism
char pop()
{
if(top==-1)
return('\0')
else
return(stack[top--]);
}
Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
Can destructor be overloaded?
assume the program must insert 4 elements from the key board and then do the following programs.sequential search(search one of the elements),using insertion sort(sort the element) and using selection sort(sort the element).
what is the sylabus for priliminaries?
Why is static class not inherited?
Is abstract thinking intelligence?
What are different oops concepts?
what is graphics
What is inheritance and how many types of inheritance?
What is class in oop with example?
What does <> mean pseudocode?
What is encapsulation c#?
what are the different types of qualifier in java?
What is byval and byref? What are differences between them?
#include
What is the real time example of inheritance?