0% found this document useful (0 votes)
27 views3 pages

Basic Stack Operations in C++

The document discusses the basic operations of a stack including push, pop, and peek. It defines a stack class with functions to perform these operations and demonstrates their use by pushing and popping an element from a sample stack object.

Uploaded by

haseeb chohan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views3 pages

Basic Stack Operations in C++

The document discusses the basic operations of a stack including push, pop, and peek. It defines a stack class with functions to perform these operations and demonstrates their use by pushing and popping an element from a sample stack object.

Uploaded by

haseeb chohan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

// stack and its basic operation

// Main operation
// 1=push; 2=pop; 3=peek

#include<iostream>
using namespace std;
class stack
{
int high,x;
public:
int z[5];// its maximum value
// here we assign constructor
stack()
{
high==0;
}

// we define basic operation that are perfome


void push(int x);
void pop();
void blank();
};
void stack::push(int x)
{
if(high==0)
{
cout<<"::its Already Empty::"<<endl;
}
else
{
z[++high]==x;
cout<<"::value inserted::"<<endl;
}
}
void stack::pop()
{
if(high==0)
{
cout<<"::its Empty::"<<endl;
}
else
{
int y=z[--high];
cout<<"::Value deleted::"<<endl;
}
}
void stack::blank()
{
if(high==0)
{
cout<<"::its Empty::"<<endl;
}
else
{
cout<<"Element Not inserted::"<<endl;
}
}
int main()
{
stack Aseem;
[Link](5);
[Link]();
[Link]();
}

You might also like