Stack operations - c++, C/C++ Programming

Assignment Help:

Stack operations - C++:

Write a program to define basic stack operations in c++.

int Stack::push(int elem)

{

   int m = getmax();

   if (top < m)

   {

      put_elem(elem,top++);

      return 0;

   }

   else

      return -1;

}

 

int Stack::pop(int& elem)

{

   if (top > 0)

   {

      get_elem(elem,--top);

      return 0;

   }

   else

      return -1;

}

 

void Stack::print()

{

   int elem;

 

   for (int i = top-1; i >= 0; --i)

   {  // Print in LIFO order

      get_elem(elem,i);

      cout << elem << "\n";

   }

}


Related Discussions:- Stack operations - c++

Inheritance, example of program to ad two numbers

example of program to ad two numbers

Develop activation tool for unattend reseal.xml, Project Description: We...

Project Description: We refurbish older computer and send them back into the market with windows 7 operating system. We are presently using windows deployment services through P

Determine the canonical form, Rule: To determine the canonical form we s...

Rule: To determine the canonical form we should OR the min terms. A min term is defined as a Boolean equation of the input if the output is logic '1'. If the input is logic '1'

I need vsti program, I need vsti program Project Description: Knowled...

I need vsti program Project Description: Knowledge of vsti programs, and music is a plus, ex: nexus I will input the sounds I just need the interface built Skills required

Flow chart, given number is prime or not

given number is prime or not

Link list, For this program you will add and test 2 new member functions to...

For this program you will add and test 2 new member functions to the IntSLList class posted on the website. The two member functions are: insertByPosn(int el, int pos) Assuming t

What are the precautions with function overloading, Precautions with functi...

Precautions with function overloading Function overloading is a boon to designers, since dissimilar names for same functions need not be thought of, which often is a cumbersome

Single string programme, write a programme that allows a user to enter 5 di...

write a programme that allows a user to enter 5 distinct words and returns them as a single string

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd