Page 116 - DCAP407_DATA_STRUCTURE
P. 116
Unit 6: Linked List Operations
node tmp;
if(last==NULL)
{
printf("list is empty\n");
return;
}
printf("contents of the list:\t");
for(tmp=last->link;tmp!=last;tmp=tmp->link)
printf("%d/n", tmp->value);
printf("%d\n", tmp->value);
}
void main()
{
node last;
int choice, num;
last=NULL;
for(;;)
{
printf("1. Insert at beginning\n");
printf("2. display\n");
printf("3. Exit\n");
printf("enter the choice/n");
scanf("%d", &choice);
switch(choice)
{
case 1:
printf("enter the number to be inserted\n");
scanf("%d", &num);
last=insert_beginning(num, last);
break;
case 2:
display(last);
break;
default:
exit(0);
}
}
LOVELY PROFESSIONAL UNIVERSITY 109