Skip to content
NIELITBHU

Complete Video Learning

  • Home
  • Shop
  • All Courses
  • Online Code Editor
  • Article
  • My account
Shop Now
Shop Now
NIELITBHU

Complete Video Learning

  • Home
  • Shop
  • All Courses
  • Online Code Editor
  • Article
  • My account

Table of Contents

  • Single Link List in C language
  • Double Link List in C Language 
Single Link List in C Language
Double Link List in C Language
Single Link List in C Language

Single Link List in C language

(Code without Any Error)

#include
#include
struct node
{
int info;
struct node *link;
};
struct node *START=NULL;
struct node * CreateNode()
{
struct node *n;
n=(struct node *)malloc(sizeof(struct node));;

return(n);

}
void insertNode()
{

struct node *temp,*t;
temp=CreateNode();
printf("Enter the number:");
scanf("%d",&temp->info);
temp->link=NULL;
if(START==NULL)
START=temp;
else{
t=START;
while(t->link!=NULL)
{
t=t->link;

}
t->link=temp;
}
}

void deleteNode()
{

struct node *r;
if(START==NULL)
printf("List is empty");
else{
r=START;
START=START->link;
free(r);
}
}

void viewList()
{

struct node *t;
if(START==NULL)
printf("List is empty");
else
{
t=START;
while(t!=NULL)
{

printf("%d \t",t->info);
t=t->link;
}
}
}
int menu()
{

int ch;
printf("\n1: Add value to the list");
printf("\n2: Delete first value");
printf("\n3: View List");
printf("\n4:Exit");
printf("\nEnter the choice");
scanf("%d",&ch);
return(ch);
}

void main()
{

while(1)
{

switch(menu())
{

case 1:
insertNode();
break;
case 2:
deleteNode();
break;
case 3:
viewList();
break;
case 4:
exit(0);
default:
printf("\nvalid choice");

}
}
}
Double Link List in C Language

Double Link List in C Language 

(Code without Any Error)

#include<stdio.h>
struct node{
int info;
struct node *prev,*next;

};
struct node *start=NULL;
void insertAsFirstNode()
{
struct node *n;
n=(struct node *)malloc(sizeof(struct node));
printf("Enter the number :");
scanf("%d",&n->info);
n->prev=NULL;
n->next=NULL;
if(start==NULL)
start=n;
else
{

start->prev=n;
n->next=start;
start=n;

}
}
void deleteFirstNode()
{

struct node *r;
if(start==NULL)
printf("List is Empty");
else
{

r=start;
start=start->next;
start->prev=NULL;
free(r);

}
}

void viewList()
{

struct node *t;
if (start==NULL)
printf("List is Empty!");
else
{

t=start;
while(t!=NULL)
{
printf("%d\t",t->info);
t=t->next;

}
}
}
int menu()
{

int a;
printf("\n 1:Add value to the list");
printf("\n 2:Delete First Node");
printf("\n 3:ViewList ");
printf("\n 4: Exit");
printf("\n\nEnter the choice :!");
scanf("%d",&a);
return(a);

}
main()
{
while(1)
{

switch(menu())
{
case 1:
insertAsFirstNode();
break;
case 2:
deleteFirstNode();
break;
case 3:
viewList();
break;
case 4:
exit(1);
default:
printf("Wrong input!");

}
}
}

Contribute Now

SHOW YOUR SUPPORT FOR NIELITBHU..!!
Dear reader, thank you for joining us. Readers like you are an inspiration for us to pursue NIELITBHU. We need your support or cooperation to further empower NIELITBHU and reach NIELITBHU more people in every corner of the country. Your every support is invaluable to our future.

आप हमें सहयोग जरुर करें (Contribute Now)

Don’t miss Join Our Community!

Email Id
Loading

Popular Courses

  • O Level
  • O level M1-R5 IT Tools & Basics of Networks
  • Pricing & FAQ
  • Term Conditions
  • Refund and Returns Policy
  • Privacy Policy
  • Contact
  • Our Team

Contact Info

Phone
011-29571528
Email
notification@nielitbhu.com

Copyright © 2025 NIELITBHU

Powered by New Idea Education Learning Information Technology Backbone Hacker Uptime (NIELITBHU)