#include<stdio.h>
#include<conio.h>
#include<alloc.h>
struct Node
{
int info;
struct Node
*link;
};
struct Node
*first;
void main()
{
create();
traverse();
insert();
}
void create()
{
struct Node
*ptr, *cpt;
char ch;
ptr=(struct
Node *) malloc(size of(struct Node));
printf(“Enter
the first Node”);
scanf(“%d”,&ptr->info);
first=ptr;
}
do
{
cpt=(struct
Node*) malloc(size of(struct Node));
printf(“Enter
the next node”);
scanf(“%d”,&cpt->info);
ptr->link=cpt;
ptr=cpt;
printf(“Enter
Y to continue”);
scanf(“%c”,&ch);
}
while(ch==’Y’);
ptr->link=first;
}
void traverse()
{
struct Node
*ptr;
printf(“Traverse
is”);
ptr=first;
while(ptr!=first);
{
printf(“%d”,ptr->info);
ptr=ptr->link;
}
}
void insert()
{
struct Node
*ptr;
ptr=(struct
Node*)malloc(size of(struct Node));
if(ptr==NULL)
}
printf(“Overflow”);
return;
}
printf(“Enter
the info into new”);
scanf(“%d”,&ptr->info);
ptr->link=start;
start=ptr;
}
No comments:
Post a Comment