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

Define the category of function - computer programming, Define the Category...

Define the Category of Function? A function, depending on whether arguments or parameters are present or not and whether a value returned or not, may belong to one of the foll

Define one's complement operator, Define One's Complement Operator? The...

Define One's Complement Operator? The one's complement operator, occasionally called the "bitwise NOT" or "bitwise complement" operator produces the bitwise one's complement of

Hwid spoofer for windows 7, Project Description: I want a simple program...

Project Description: I want a simple program that will spoof my hardware id. I should be able to prepare the id to spoof to in the program and press "random" button to spoof to

C program for reverse the word in string, C Program for REVERSE THE WORD IN...

C Program for REVERSE THE WORD IN STRING #include conio.h> #include stdio.h> #include string.h> void main() {           char a[50],b[25][25],temp;           i

Wap for the game hangman-using functions with txt graphics, The game of han...

The game of hangman may have originated in the Victorian era, and involves trying to guess a word by suggesting letters. The game is played as follows: A word is chosen and the pl

Program for manage the tasks of a robot, Consider a group of n robots, numb...

Consider a group of n robots, numbered R2D1 through R2Dn, and m tasks, numbered 1 through m. Tasks can be different and robots are specialized, hence a given robot can only perform

Data structure, how to convert a general tree into binary tree with example...

how to convert a general tree into binary tree with example

Arrays, how to avoid duplicates strings in an array

how to avoid duplicates strings in an array

Creates and implements a class to represent the queue, Purpose This ass...

Purpose This assignment is an exercise in implementing the queue ADT using a singly-linked list. This assignment also introduces the concept of templates. Assignment Th

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