#include<iostream>
using namespace std;
int t = -1;
int a[100];
void push(int b)
{
t++;
a[t] = b;
}
void pop()
{
t--;
}
void print()
{
int i;
cout << "Current Stack :: ";
for(i=0;i<=t;i++)
{
cout << a[i] << " ";
}
cout << endl;
}
int main()
{
push(5);
push(4);
push(3);
push(2);
push(1);
print();
pop();
print();
return 0;
}
using namespace std;
int t = -1;
int a[100];
void push(int b)
{
t++;
a[t] = b;
}
void pop()
{
t--;
}
void print()
{
int i;
cout << "Current Stack :: ";
for(i=0;i<=t;i++)
{
cout << a[i] << " ";
}
cout << endl;
}
int main()
{
push(5);
push(4);
push(3);
push(2);
push(1);
print();
pop();
print();
return 0;
}
Comments
Post a Comment