Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Data File StructureRSS Feeds

Program to perform stack operations using array

Posted By: Easy Tutor     Category: C++ Programming     Views: 17283

Write a Program to perform stack operations using array.

Code for Program to perform stack operations using array in C++ Programming

#include <iostream.h>
#include <conio.h>
#define MAX 10
#define MIN 0
#include "stack.cpp"void main(){
   int choice;
   stack obj;
   while(1){
   clrscr();
   cout<<"\n\t\tÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\n";
   cout<<"\t\t³  STACK OPERATIONS USING ARRAY   ³\n";
   cout<<"\t\tÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\n";
   cout<<"\t\t³  1) PUSH                        ³\n";
   cout<<"\t\t³  2) POP                         ³\n";
   cout<<"\t\t³  3) PEEP                        ³\n";
   cout<<"\t\t³  4) CHANGE                      ³\n";
   cout<<"\t\t³  5) STATUS                      ³\n";
   cout<<"\t\t³  6) DISPLAY                     ³\n";
   cout<<"\t\t³  7) EXIT                        ³\n";
   cout<<"\t\tÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\n";
   cout<<"\t\tEnter your Choice :  ";
   cin>>choice;
   int item,index;
   switch(choice){
     case 1 :  cout<<"\n\n\t\t*****PUSH*****\n";
           cout<<"\t\tEnter item to be pushed : ";
           cin>>item;
           obj.push(item);
           break;
     case 2 :  cout<<"\n\n\t\t*****POP*****\n";
           item=obj.pop();
           if(item!=-111){
              cout<<"\n\t\tItem being poped out is : "<<item;
              getch();
           }
           break;
     case 3 :  cout<<"\n\n\t\t*****PEEP*****\n";
           cout<<"\t\tEnter index for item to be peeped : ";
           cin>>index;
           item=obj.peep(index);
           if(item!=-111){
              cout<<"\n\t\tItem to be peeped is : "<<item;
              getch();
           }
           break;
     case 4 :  cout<<"\n\n\t\t*****CHANGE*****\n";
           cout<<"\t\tEnter index for item to be changed : ";
           cin>>index;
           cout<<"\t\tEnter item value for it : ";
           cin>>item;
           obj.change(index,item);
           break;
     case 5 :  cout<<"\n\n\t\t*****STATUS*****\n";
           cout<<"\n\t\tTotal Elements are : "<<obj.status();
           getch();
           break;
     case 6 :  cout<<"\n\n\t\t*****DISPLAY*****\n";
           obj.display();
           break;
     case 7 :  gotoout;
     default:  cout<<"\n\n\t\tInvalid Choice\n\n";
           getch();
           break;
   }
 }
 out:
}
  
Share: 


Didn't find what you were looking for? Find more on Program to perform stack operations using array Or get search suggestion and latest updates.

Easy Tutor
Easy Tutor author of Program to perform stack operations using array is from United States. Easy Tutor says

Hello Friends,

I am Free Lance Tutor, who helped student in completing their homework.

I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.

I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] com

I have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada.

I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.

Thanks,
Happy Programming :)

 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!