#include<stdio.h>
#include<stdlib.h>
struct student
{
int rno;
struct student*next;
};
int main()
{
struct student*head,*temp,*newnode;
int choice;
head=NULL;
do
{
printf("\nMENU");
printf("\n 1.INSERT BEGINNING\n2.DELETE BEGINNING\n3.DISPLAY\n4.EXIT");
printf("\nEnter your Choice");
scanf("%d",&choice);
switch(choice)
{
case 1:
newnode=(struct student*)malloc(sizeof(struct student));
printf("Enter Roll No:");
scanf("%d",&newnode->rno);
if(head==NULL)
{
head=newnode;
newnode->next=NULL;
}
else
{
newnode->next=head;
head=newnode;
}
printf("%d is inserted at beginning\n",newnode->rno);
break;
case 2:
if(head==NULL)
printf("Linked List is Empty\n");
else
{
temp=head;
head=head->next;
printf("%d is deleted at beginning\n",temp->rno);
free(temp);
}
break;
case 3:
if(head==NULL)
printf("Linked List is Empty\n");
else
{
temp=head;
printf("Contents of linked list\n");
while(temp!=NULL)
{
printf("\t%d",temp->rno);
temp=temp->next;
}
}
break;
case 4:
printf("Exiting the linked lidt");
break;
default:printf("Invalid Option\n");
}
}
while(choice!=4);
return 0;
}