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

Basic Stack Operations in C++

The document describes a C++ implementation of a stack data structure with basic operations: push, pop, and blank. The stack can hold a maximum of 5 elements and includes methods to insert and remove elements, as well as check if it is empty. The main function demonstrates the usage of these operations by creating a stack instance and performing push, pop, and blank operations.

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 PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Basic Stack Operations in C++

The document describes a C++ implementation of a stack data structure with basic operations: push, pop, and blank. The stack can hold a maximum of 5 elements and includes methods to insert and remove elements, as well as check if it is empty. The main function demonstrates the usage of these operations by creating a stack instance and performing push, pop, and blank operations.

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