Single Link List insert last Code in C Programming Turbo C
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCL6H0mnO8-_mPNhHK4I6Zp6VKjvB-OFXhH0xOqChxexf0r3ScBDthmBY1Sn5GzxQ9vlBOUIk3100XoZ_wgLTW8lcXMBlZa-s-oqFPBusmt2XHs_ZmAQn_r_76xELfe42sSVpXn6rkmI-N/s400/C+Program.jpg)
#include<stdio.h>
#include<conio.h>
struct linklist
{
int
no;
struct
linklist *next;
};
typedef
struct linklist node;
void main()
{
void
display(node*);
void
create(node*);
void
insertlast(node *);
node*head;
clrscr();
head=(node*)malloc(sizeof(node));
create(head);
insertlast(head);
display(head);
getch();
}
void
create(node* list)
{
printf("Enter
no,-1 for end");
scanf("%d",&list->
no);
if(list->
no==-1)
list->
next=NULL;
else
{
list->next=(node*)
malloc(sizeof(node));
create
(list-> next);
}
}
void
display(node * list)
{
while(list->
next!=NULL)
{
printf("%d",list->no);
list=list->
next;
}
}
void insertlast(node *list)
{
node
*new1;
new1=(node
*)malloc(sizeof(node));
while(list->next!=NULL)
{
list=list->next;
}
list->next=new1;
new1->next=NULL;
printf("Enter
no");
// list->no=100;
scanf("%d",&list->no);
}
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment