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
What is oops and its features?
Whats oop mean?
What is a function in oop?
class type to basic type conversion
write a program to find 2 power of a 5digit number with out using big int and exponent ?
What is an advantage of polymorphism?
What is polymorphism oop?
Why can't we have instance(stack) of a class as a member of the same class like eg.Class A{A obj;} as we can have self refential pointer
This program numbers the lines found in a text file. Write a program that reads text from a file and outputs each line preceded by a line number. Print the line number right-adjusted in a field of 3 spaces. Follow the line number with a colon, then one space, then the text of the line. You should get a character at a time and write code to ignore leading blanks on each line. You may assume that the lines are short enough to fit within a line on the screen. Otherwise, allow default printer or screen output behavior if the line is too long (i.e., wrap or truncate). A somewhat harder version determines the number of spaces needed in the field for the line numbers by counting lines before processing the lines of the file. This version of the program should insert a new line after the last complete word that will fit within a 72-character line.
How long to learn object oriented programming?
what type of questions
Why is oop better than procedural?
What is object in oop with example?
What is inheritance in simple words?
Which type does string inherit from?