What do you mean by stack program?
Get me an example stack program?
Answers were Sorted based on User's Feedback
Answer / harshita gangwar
<STACK>
stack is a linear kind of data structure .it works on "LIFO"
,LIFO stands for last in first out. in stack we perform two
operations i.e. insertion & deletion & these operations
performs only at one end i.e called "TOP".
for eg: a stack of books..etc
there are two operations performs-
(1) push (2) pop
there are also two conditions occures in case of stack i.e.
i.e. (i)underflow (ii)overflow
/*ALGO FOR PUSH OPERATION*/
PUSH( stack[],TOP,item, len)
1) set TOP=-1
2) if TOP==len-1, then
print stack is overflow.
3) else
set TOP=TOP+1
set stack[TOP]=item
4) EXIT.
In the PUSH operation the overflow condition generates.
/*ALGO FOR POP OPERATION*/
POP(stack[],TOP,item,len)
1) set TOP=len-1
2) if TOP==-1, then
print stack is underflow.
3) else
set item=stack[TOP]
set TOP=TOP-1
4) EXIT.
In the POP operation the underflow condition generates.
OTHER EGS OF STACK:-
(I)a stack of disks.
(II)a common model of a stack is plates in a party
where fresh plates are "PUSHED"(inserting) on to the TOP &
"POPED"(deleting) from the TOP.
Is This Answer Correct ? | 11 Yes | 0 No |
Answer / manoj singh
stac program is called whose as provide the lifo mens last input first output .when we putdown the value in node thats called pop and flow out the value thats called push.
char stack[10]
int top=-1;
void push(char d)
{
if(to==9)
printf("stack is full");
else
stack[++top]=d;
}
char pop()
{
if(top==-1)
return('\0')
else
return(stack[top--]);
}
//stack is create both performance pop and push.
Is This Answer Correct ? | 8 Yes | 2 No |
Answer / 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 |
Answer / abcdkr
Manoj Singh
I am very sorry to say that I didn't understand the program.
I am just in eleventh standard.
please help me out line by line.
Thank YOu!
Is This Answer Correct ? | 3 Yes | 3 No |
diff between Virtual mathod and abstract method?
What is operator overloading? Give Example
11 Answers CTS, IBM, TCS,
what is the size of an empty class
Round up a Decimal number in c++.. example Note = 3.5 is as 4 3.3 is as 3
3 Answers Accenture, Cognizant, IBM,
When you define a integer it gets stored in which data structure?(Stack or a heap)
what is polymorpsim? what are its types?
Why do we use inheritance?
explain dynamic binding by drowing
Why oops is important?
Why is static class not inherited?
What does no cap mean?
What is command routing in MFC