Wednesday, August 28, 2013

C++ Program to push an item in a stack

#include<iostream>
using namespace std;
int main(){
int stack[10],top=-1,n,i;
if(top==9)
cout<<"Stack is Full";
else{
cout<<"Enter the item to be inserted:";
cin>>n;
top=top+1;
stack[top]=n;
}
cout<<"You have inserted:";
cout<<stack[top];
return 0;
}

Output:-




No comments:

Post a Comment

Ads Inside Post