What do you mean by stack program?
Get me an example stack program?

Answers were Sorted based on User's Feedback



What do you mean by stack program? Get me an example stack program?..

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

What do you mean by stack program? Get me an example stack program?..

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

What do you mean by stack program? Get me an example stack program?..

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

What do you mean by stack program? Get me an example stack program?..

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

Post New Answer

More OOPS Interview Questions

Write a program to multiply 3x3 matrics

1 Answers  


You have one base class virtual function how will call that function from derived class?

4 Answers  


What is class and example?

0 Answers  


Can private class be inherited?

0 Answers  


hi all..i want to know oops concepts clearly can any1 explain??

0 Answers   Eureka Forbes,






Please tell me the oops concept with detailed answer

9 Answers   EEE,


What is multilevel inheritance?

0 Answers  


What are the features of oop?

0 Answers  


Question: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date.

0 Answers  


What is the importance of oop?

0 Answers  


143.what is oops principles?

10 Answers  


What is a friend function & its advantage?

2 Answers   TCS,


Categories