SlideShare a Scribd company logo
1 of 2
Stack usingan array
#include<iostream .h>
#include <conio.h>
#define ms5
Class stack
{
Int a[ms],size ,top;
Public:
Stack(int n);
{
Size =n;
Top=-1;
}
Void push();
Void push();
Void display();
};
Void stack::push()
{
Int x;
If(top<=size-1)
{
Cout<<”enter the value”;
Cin>>x;
top++;
a[top]=x;
}
else
cout<<”stackis overflow”;
}
Void stack::pop()
{
int y;
if(top==-1)
cout<<”stackis empty”;
else
{
Y=a[top];
Cout<<”the deletedvalue is :”<< y;
Top--;
}
}
Void stack ::display()
{
Int i;
If (top==-1)
Cout<<”stackis empty”;
Else
{
Cout<<”stackis empty“;
Else
{
cout <<”the element of stack”;
for

More Related Content

What's hot

What's hot (20)

Pruebabfs
PruebabfsPruebabfs
Pruebabfs
 
Tablas hash (Rubén Ndong Obiang)
Tablas hash (Rubén Ndong Obiang)Tablas hash (Rubén Ndong Obiang)
Tablas hash (Rubén Ndong Obiang)
 
Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3
 
listing output program C
listing output program Clisting output program C
listing output program C
 
Los fantastico
Los fantasticoLos fantastico
Los fantastico
 
memoria dinamica
memoria dinamicamemoria dinamica
memoria dinamica
 
Python codigo graficas
Python codigo graficasPython codigo graficas
Python codigo graficas
 
Alocação Dinâmica em C
Alocação Dinâmica em CAlocação Dinâmica em C
Alocação Dinâmica em C
 
Rafaeltorres
RafaeltorresRafaeltorres
Rafaeltorres
 
(Meta 4) ejemplo calcular la mitad de un numero dev c++
(Meta 4) ejemplo calcular la mitad de un numero dev c++ (Meta 4) ejemplo calcular la mitad de un numero dev c++
(Meta 4) ejemplo calcular la mitad de un numero dev c++
 
C Program : Sorting : Bubble,
C Program : Sorting : Bubble, C Program : Sorting : Bubble,
C Program : Sorting : Bubble,
 
Fcfs Cpu Scheduling With Gantt Chart
Fcfs Cpu Scheduling With Gantt ChartFcfs Cpu Scheduling With Gantt Chart
Fcfs Cpu Scheduling With Gantt Chart
 
Kelompok 2.6
Kelompok 2.6Kelompok 2.6
Kelompok 2.6
 
Fibonacci
FibonacciFibonacci
Fibonacci
 
Sequential
Sequential Sequential
Sequential
 
Scanfill polygon
Scanfill polygonScanfill polygon
Scanfill polygon
 
contoh Program C++ tentang fungsi for
contoh Program C++ tentang fungsi forcontoh Program C++ tentang fungsi for
contoh Program C++ tentang fungsi for
 
Linked List Implementation of Stack in C
Linked List Implementation of Stack in CLinked List Implementation of Stack in C
Linked List Implementation of Stack in C
 
Linker
LinkerLinker
Linker
 
Numeros primos
Numeros primosNumeros primos
Numeros primos
 

Viewers also liked

Viewers also liked (17)

Docente martha polo barrera
Docente martha polo barreraDocente martha polo barrera
Docente martha polo barrera
 
Mapa conceptual
Mapa conceptualMapa conceptual
Mapa conceptual
 
Flow Chart
Flow ChartFlow Chart
Flow Chart
 
Psicologia educativa
Psicologia educativaPsicologia educativa
Psicologia educativa
 
Mapa conceptual
Mapa conceptualMapa conceptual
Mapa conceptual
 
Troll aitormarti
Troll aitormartiTroll aitormarti
Troll aitormarti
 
Digipak analysis
Digipak analysisDigipak analysis
Digipak analysis
 
Trabajo en equipo1
Trabajo en equipo1Trabajo en equipo1
Trabajo en equipo1
 
Parque acuático dios padre
Parque acuático dios padreParque acuático dios padre
Parque acuático dios padre
 
SchoolCounselingResumeUpdated (Autosaved)
SchoolCounselingResumeUpdated (Autosaved)SchoolCounselingResumeUpdated (Autosaved)
SchoolCounselingResumeUpdated (Autosaved)
 
Reflexion modulo 4
Reflexion modulo 4Reflexion modulo 4
Reflexion modulo 4
 
Zohar placed in oslo as of february 2016
Zohar placed in oslo as of february 2016Zohar placed in oslo as of february 2016
Zohar placed in oslo as of february 2016
 
Archivo PDF
Archivo PDFArchivo PDF
Archivo PDF
 
placement resume 474(tech)
placement resume 474(tech)placement resume 474(tech)
placement resume 474(tech)
 
Engineers And Technicians For Germany
Engineers And Technicians For GermanyEngineers And Technicians For Germany
Engineers And Technicians For Germany
 
Calendário do concurso 2012
Calendário do concurso 2012Calendário do concurso 2012
Calendário do concurso 2012
 
ASITF (English)_ASITF Certificate
ASITF (English)_ASITF CertificateASITF (English)_ASITF Certificate
ASITF (English)_ASITF Certificate
 

Ds program

  • 1. Stack usingan array #include<iostream .h> #include <conio.h> #define ms5 Class stack { Int a[ms],size ,top; Public: Stack(int n); { Size =n; Top=-1; } Void push(); Void push(); Void display(); }; Void stack::push() { Int x; If(top<=size-1) { Cout<<”enter the value”; Cin>>x; top++; a[top]=x; } else cout<<”stackis overflow”; } Void stack::pop() { int y; if(top==-1)
  • 2. cout<<”stackis empty”; else { Y=a[top]; Cout<<”the deletedvalue is :”<< y; Top--; } } Void stack ::display() { Int i; If (top==-1) Cout<<”stackis empty”; Else { Cout<<”stackis empty“; Else { cout <<”the element of stack”; for