answersLogoWhite

0


Best Answer

void push(int y) { if(top>stackSize) { cout<<"stack full"<<endl; return; } else { top++; stack[top]=y; } } int pop() { int a; if(top<=0) { cout<<"stack is empty"<<endl; return 0; } else { a=stack[top]; top--; } return(a); }

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: 'write a simple program for stack operation in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a c program to perform stack operation?

int top=-1; int stack[10];


Write a program to convert stack into queue using c language?

In order to write a program to convert stack into queue using c language you must be able to identify the proper program. Having a special certification in programing will be beneficial as well to make sure you recognize the proper queues for the programs.


What are processes in operating system?

To put it in simple terms, we write our computer programs in a text file and when we execute this program, it becomes a process which performs all the tasks mentioned in the program. When a program is loaded into the memory and it becomes a process, it can be divided into four sections &#9472; stack, heap, text and data


Write a c program to sort an unsorted stack?

A stack is implicitly sorted by hierarchical nested order. It does not make sense to sort a stack. Do you mean a list? If so, please ask the question again.


What are process states in operating system?

To put it in simple terms, we write our computer programs in a text file and when we execute this program, it becomes a process which performs all the tasks mentioned in the program. When a program is loaded into the memory and it becomes a process, it can be divided into four sections &#9472; stack, heap, text and data


Write a c program for false position method?

Write a simple program in finding roots x^3-6x^2+11x-6.1=0


Write a sequence of instruction to exchange two register contents using stack in 8086 processor?

To exchange two registers, say the BX and CX registers, in the 8086 using the stack, you can use...PUSH BXPUSH CXPOP BXPOP CX... Of course, this is for 16 bit operation. If you want 8 bit operation, you will need to do more than that, because stack operations are always 16-bit operations.


Who writes the lyrics for short stack?

Short Stack write their own lyrics.


Write a java program to implement stack in java?

You would need an array to store the actual stack. Better use an ArrayList or some other structure that you can redimension. You'll also need a variable to point to the "top of stack" - the last element added, which is the first element to be taken away.


How do fixed a stack overflow at line 203?

Allocate more memory to the stack or write code that does not leave stuff on the stack.


How do you write a C program to find the Simple Interest?

Reference:cprogramming-bd.com/c_page1.aspx#simpleinterest


Algorithm for conversion from prefix to infix?

The belt-and-braces technique is easy enough: &gt; &gt; prefix_to_infix(stream, stack) &gt; if stack is not empty &gt; pop a node off the stack &gt; if this node represents an operator &gt; write an opening parenthesis to stream &gt; prefix_to_infix(stream, stack) &gt; write operator to stream &gt; prefix_to_infix(stream, stack) &gt; write a closing parenthesis to stream &gt; else &gt; write value to stream &gt; endif &gt; endif &gt; endfunc