#include<stdio.h>
#include<conio.h>
#include<malloc.h>
#include<process.h>
struct node
{
int data;
struct node *next;
}*start=NULL;
void end_insert();
int main()
{
int ch;
printf("1.To insert at end\n");
printf("0.To exit\n");
printf("\nEnter your choice....\n");
scanf("%d",&ch);
switch(ch)
{
case 1: end_insert();
break;
case 0: exit(0);
default:printf("\nPlease enter a valid choice");
}
}
void end_insert()
{
struct node *r;
int d;
r=(struct node*)malloc(sizeof(struct node));
printf("\nEnter data to insert.");
scanf("%d",&d);
r->data=d;
r->next=NULL;
if(start==NULL)
start=r;
else
{
struct node*temp;
for(temp=start;temp->next!=NULL;temp=temp->next);
temp->next=r;
}
}
#include<conio.h>
#include<malloc.h>
#include<process.h>
struct node
{
int data;
struct node *next;
}*start=NULL;
void end_insert();
int main()
{
int ch;
printf("1.To insert at end\n");
printf("0.To exit\n");
printf("\nEnter your choice....\n");
scanf("%d",&ch);
switch(ch)
{
case 1: end_insert();
break;
case 0: exit(0);
default:printf("\nPlease enter a valid choice");
}
}
void end_insert()
{
struct node *r;
int d;
r=(struct node*)malloc(sizeof(struct node));
printf("\nEnter data to insert.");
scanf("%d",&d);
r->data=d;
r->next=NULL;
if(start==NULL)
start=r;
else
{
struct node*temp;
for(temp=start;temp->next!=NULL;temp=temp->next);
temp->next=r;
}
}

//struct node *start=NULL;
ReplyDeletehw wil we understand whether the value is inserted or not??you are not dislaying the result
ReplyDeleteif the link list isnt defined...how can a user insert at the end???
ReplyDelete