#include
#include
#include
#include
struct node
{
char info;
int data;
node *link;
}*top,*temp;
void main()
{
clrscr();
top=0;
int ch;
ch=0;
char c;
while(ch==0)
{
cout<
cin>>ch;
switch(ch)
{
case 1:
{
do
{
temp=(node *)malloc(sizeof(node));
cout<<"enter the data/element::";
cin>>temp->data;
temp->link=top;
top=temp;
cout<<"do you still want to insert(y/n): ";
cin>>c;
}while (c=='y' || c=='Y');
if(c=='n' || c=='N')
{
ch=0;
break;
}
}
case 2:
{
int item;
if(top==0)
{
cout<
break;
}
else
{
do
{
item=top->data;
top=top->link;
cout<<"deleted element is::"<
}while((c=='y'|| c=='Y')&& top->data!=0);
if(c=='n' || c=='N')
{
ch=0;
break;
}
if(top==0)
{
cout<
break;
}
}
}
case 3:
{
char item;
char a[20];
top=0;
cout<
for(int i=0;a[i]!='\0';i++)
{
temp=(node *)malloc(sizeof(node));
temp->info=a[i];
temp->link=top;
top=temp;
}
while(top!=0)
{
item=top->info;
top=top->link;
cout<
cout<
break;
}
case 4:
{
ch=5;
exit(0);
}
}
}
getch();
}
No comments:
Post a Comment