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++

Verification class, I need help to understand and do this assignment ******...

I need help to understand and do this assignment ********************************************************* You are to insert the missing code in the C program given for combinatio

Microprocessors and motherboards, The heart of the modern electronic system...

The heart of the modern electronic system is the microprocessor e.g. the video, sound, game consoles, portable phones and domestic appliances. Let us consider the heart of a home c

Define bitwise-and operator, Define Bitwise-AND Operator: &:? The bitwi...

Define Bitwise-AND Operator: &:? The bitwise-AND operator (&) compares every bit of its first operand to the corresponding bit of its second operand. If both bits are 1 the mat

Pointer declaration for class, P o i n t e r d e c l ...

P o i n t e r d e c l a r a t i o n f o r C l a s s : M m; M * p m; / / C la ss M i s d e c l a r e d a s

For loop, minimum of seven number

minimum of seven number

What does it mean to declare a destructor as static, d) a "static destructo...

d) a "static destructor" is a static member function of the class which accepts one argument - a pointer to the object of that class to be cracked. It is probably utilized along wi

Object oriented programming and cryptography, This assignment document will...

This assignment document will be distributed from Blackboard assignment folder. Some parts of the assignments will require you to research answers from your text book (you must rea

Quicksorting in linked lists, How do i write a code in C++ to bubblesort in...

How do i write a code in C++ to bubblesort in linked list

Write a structured and annotated c program, Intelligent homes are becoming ...

Intelligent homes are becoming increasingly popular as the cost/performance ratio of microcontrollers is continuously dropping.  These systems incorporate various transducers to de

Explain type casting, Type Casting Implicit type conversions, as allowe...

Type Casting Implicit type conversions, as allowed by the language, can lead to errors creeping in the program if care is not taken. Thus, explicit type conversions may be used

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