#include<stdio.
h>
#include<stdlib.h>
struct slinklist
int data;
struct slinklist *next;
};
typedef struct slinklist node;
node *start=NULL;
int menu()
int ch;
printf("\n [Link] the list");
printf("\n 2. insert a node at beginning");
printf("\n 3. delete a node at end");
scanf("%d",&ch);
return ch;
node *getnode()
node *newnode;
newnode=(node*)malloc(sizeof(node));
printf("enter the data");
scanf("%d",&newnode->data);
newnode->next=NULL;
return newnode;
int countnode(node*ptr)
int count=0;
while(ptr!=NULL)
count++;
ptr=ptr->next;
return count;
void creatlist(int n)
int i;
node *newnode;
node *temp;
for(i=0;i<n;i++)
newnode=getnode();
if(start==NULL)
start=newnode;
else
temp=start;
while(temp->next!=NULL)
temp=temp->next;
temp->next=newnode;
void display()
node *temp;
temp=start;
printf("\n the contents of the list");
if(start==NULL)
printf("list is empty");
else
while(temp!=NULL)
printf("%d->",temp->data);
temp=temp->next;
void insert_at_beg()
node *newnode;
newnode=getnode();
if(start==NULL)
start=newnode;
else
newnode->next=start;
start=newnode;
void delete_at_last()
node *temp,*prev;
if(start==NULL)
printf("\n empty list");
else{
temp=start;
prev=start;
while(temp->next!=NULL)
prev=temp;
temp=temp->next;
void main()
int ch,n;
while(1)
ch=menu();switch(ch);
case1:if(start==NULL)
printf("node you can creat");
scanf("%d",&n);
creatlist(n);
printf("list created");
else
printf("\n list is created");
break;
case2: insert_at_beg();
break;
case3: delete_at_last();
break;
Output:- #include<stdio.h>
#include<stdlib.h>
struct slinklist
int data;
struct slinklist *next;
};
typedef struct slinklist node;
node *start=NULL;
int menu()
int ch;
printf("\n [Link] the list");
printf("\n 2. insert a node at beginning");
printf("\n 3. delete a node at end");
scanf("%d",&ch);
return ch;
node *getnode()
node *newnode;
newnode=(node*)malloc(sizeof(node));
printf("enter the data");
scanf("%d",&newnode->data);
newnode->next=NULL;
return newnode;
int countnode(node*ptr)
int count=0;
while(ptr!=NULL)
count++;
ptr=ptr->next;
return count;
void creatlist(int n)
int i;
node *newnode;
node *temp;
for(i=0;i<n;i++)
newnode=getnode();
if(start==NULL)
start=newnode;
else
temp=start;
while(temp->next!=NULL)
temp=temp->next;
temp->next=newnode;
}
}
void display()
node *temp;
temp=start;
printf("\n the contents of the list");
if(start==NULL)
printf("list is empty");
else
while(temp!=NULL)
printf("%d->",temp->data);
temp=temp->next;
void insert_at_beg()
node *newnode;
newnode=getnode();
if(start==NULL)
start=newnode;
else
newnode->next=start;
start=newnode;
}
void delete_at_last()
node *temp,*prev;
if(start==NULL)
printf("\n empty list");
else{
temp=start;
prev=start;
while(temp->next!=NULL)
prev=temp;
temp=temp->next;
void main()
int ch,n;
while(1)
ch=menu();switch(ch);
case1:if(start==NULL)
printf("node you can creat");
scanf("%d",&n);
creatlist(n);
printf("list created");
else
printf("\n list is created");
break;
case2: insert_at_beg();
break;
case3: delete_at_last();
break;
Output:- #include<stdio.h>
#include<stdlib.h>
struct slinklist
int data;
struct slinklist *next;
};
typedef struct slinklist node;
node *start=NULL;
int menu()
int ch;
printf("\n [Link] the list");
printf("\n 2. insert a node at beginning");
printf("\n 3. delete a node at end");
scanf("%d",&ch);
return ch;
}
node *getnode()
node *newnode;
newnode=(node*)malloc(sizeof(node));
printf("enter the data");
scanf("%d",&newnode->data);
newnode->next=NULL;
return newnode;
int countnode(node*ptr)
int count=0;
while(ptr!=NULL)
count++;
ptr=ptr->next;
return count;
void creatlist(int n)
int i;
node *newnode;
node *temp;
for(i=0;i<n;i++)
newnode=getnode();
if(start==NULL)
start=newnode;
else
{
temp=start;
while(temp->next!=NULL)
temp=temp->next;
temp->next=newnode;
void display()
node *temp;
temp=start;
printf("\n the contents of the list");
if(start==NULL)
printf("list is empty");
else
while(temp!=NULL)
printf("%d->",temp->data);
temp=temp->next;
void insert_at_beg()
node *newnode;
newnode=getnode();
if(start==NULL)
start=newnode;
else
newnode->next=start;
start=newnode;
void delete_at_last()
node *temp,*prev;
if(start==NULL)
printf("\n empty list");
else{
temp=start;
prev=start;
while(temp->next!=NULL)
prev=temp;
temp=temp->next;
void main()
int ch,n;
while(1)
ch=menu();switch(ch);
{
case1:if(start==NULL)
printf("node you can creat");
scanf("%d",&n);
creatlist(n);
printf("list created");
else
printf("\n list is created");
break;
case2: insert_at_beg();
break;
case3: delete_at_last();
break;
Output:- [Link] the list
2. insert a node at beginning
3. delete a node at end
Input 3
Node you can creat 3
Ether data 55
Enter data 78
Enter data 88
List created.