Professional Documents
Culture Documents
//#include<conio.h>
int pop();
void push(int);
//stack declaration
struct stack{
int info;
stack *next;
};
if(top == NULL)
top = temp;
else{
temp->next = top;
top = temp;
}
cout<<" \n The value pushed into stack is "<<top->info;
}
int y;
if(top == NULL){
cout<<"stack underflow.";
return 0 ;
}
y = top->info;
temp = top;
top = top->next;
delete temp;
return y;
}
void topvalue(){
cout<<"\n The value at the top of the stack is "<< top->info;
}
int main(){
//clrscr();
push(10);
push(20);
cout<< "\nPoped value is "<<pop();
topvalue();
push(30);
push(40);
cout<< "\nPoped value is "<<pop();
topvalue();
push(50);
push(60);
cout<< "\nPoped value is "<<pop();
topvalue();
//getch();
return 0;