C++ Program implement a stack using an array
C++ Program implement a stack using an array.
/************************************************************** Author: Arun Vishnu M V Web: www.arunmvishnu.com Description: C++ Program implement a stack using an array ***************************************************************/ #include<conio.h> #include<iostream.h> #include<process.h> void main() { int stack[150],top,n,i,max_stack,choice,element,n_pop; max_stack=150; cout<<"How many elements are in the stack: "; cin>>n; cout<<"Enter "<>stack[top]; cout<<"\nStack is implemented.\nThe stack is\n"; for(i=top-1;i>=0;i--) cout< >choice; switch(choice) { case 1: // PUSH cout<<"\nPUSH OPERATION\n"; if(top>=max_stack) { cout<<"Stack is full!"; getch(); break; } cout<<"Enter an element: "; cin>>element; stack[top]=element; top++; cout<<"Item Inserted!"; getch(); break; case 2: // POP cout<<"POP OPERATION\n"; if(top<0) { cout<<"Stack is empty"; getch(); break; } cout<<"How many elements you want to pop: "; cin>>n_pop; if(n_pop>top) { cout<<"\nError!\nStack is small."; getch(); break; } top=top-n_pop; cout<<"Items POPed"; getch(); break; case 3: // Display cout<<"\The stack is\n"; for(i=top-1;i>=0;i--) cout<< stack[i] <<" "; getch(); break; case 4: exit(0); getch(); default: cout<<"RE-enter your choice!"; } // End of switch } // End of while getch(); } //---------------------- END--------------------
sorry, your programs are just awesome but this one contain a bug in 12 th line
ohhh yea.. thx Anoop.. it caused when i edited it for formating in web :(..
Hi Mr.Arun,
Warm Greetings.
I am presently studing BSc-IT and am preparing for my semester exams which will be commencing from 5th July’10 onwards.
Unfortunately, our university failed to upload the lab questions list on Data Structures using C++ during the beginning of the semester due to some technical reasons..Therefore I am in trouble as I could not get program codes for 11 programs (Questions) from that very list and my faculty is on sick leave.
Please help me….Thank you in advance
nice….keep it up
plz give me o/p of this stack array prog
Can I get each and every program of C++ in this website ?
i AM IN A ds LAB DUNNO ANYTHIN ABOUT IT :d ha ha ha
hi.,
mr.Arun sir ….
I’m a student of B.Tech.II nd year.of computer science…i want to do some new..plz help me………
mr.Arun sir,cn dis program be done in some other way?????please tell me the logic behind it…..is dis always necessary to use push n pop function……please tell me the logic in detail…
Some code formatting plugins used in this site making some issues in the code.. Few lines of codes were hidden due to the same issue. Cleared the cache and now you will get the complete program.
hi sir,
i am doing my ECE second year IN CHENNAI.i dont have an idea about writing a program in datastructures(array implementation,pointer implementation of list,stack),can u please help me with the basics and can u send me the program with brief explanation?
if you send me the program it would be really helpful to me.thank you…..
plzz give me this programmme by multilevel inheritence in c++ code….