Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Linked List Program in C
WhatsApp
Ashish Srivastava
Apr 24
2016
925
0
0
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
void
main()
{
struct
node
{
int
num;
struct
node *ptr;
};
typedef
struct
node NODE;
NODE *head, *first, *temp;
int
count=0;
int
choice=1;
first=NULL;
while
(choice)
{
head=(NODE *)malloc(
sizeof
(NODE));
printf(
"Enter the data item\n"
);
scanf(
"%d"
,&head->num);
if
(first!=NULL)
{
temp->ptr=head;
temp=head;
}
else
{
first=temp=head;
}
fflush(stdin);
printf(
"Do you want to continue(type 0 or 1)?\n"
);
scanf(
"%d"
,&choice);
}
temp->ptr=NULL;
temp=first;
printf(
"Status of the linked list is\n"
);
while
(temp!=NULL)
{
printf(
"%d"
,temp->num);
count++;
temp=temp->ptr;
}
printf(
"NULL"
);
printf(
"NO of nodes in the list =%d\n"
,count);
getch();
}
Linked list program
C Language
Up Next
Linked List Program in C