programminginc.net

C Language Programming

  • Home
  • C Examples
Home > Data Structure C Programming Examples > Singly Linked List Data Structure Program C

Singly Linked List Data Structure Program C

Singly Linked List Data Structure Program using Pointers in C Language Programming is as follows.

#include<stdio.h>
#include<conio.h>
#include<alloc.h>
struct linkedlist
{
int info;
struct linkedlist *next;
};
typedef struct linkedlist node;
node* makenode(int);
main()
{
node *head, *p, *z;
int x; char c='y';
clrscr();
printf("Enter the number");
scanf("%d", &x);
head=makenode(x);
p=head;
printf("\nDo you want to continue\n");
fflush(stdin);
scanf("%c", &c);
while(c!='n')
{
printf("\nEnter the Number");
scanf("%d", &x);
z=makenode(x);
p->next=z;
p=z;
printf("\nDo you wan to continue\n");
fflush(stdin);
scanf("%c", &c);
}
p=head;
while(p!=NULL)
{
printf("\t%d", p->info);
p=p->next;
}
getch();
return 0;
}
node* makenode(int x)
{
node *z;
z=(node*) malloc(sizeof(node));
z->info=x;
z->next=NULL;
return z;
}
//end of program//
  • Singly Linked List Data Structure Program C
  • C program to insert a node in singly linked list
  • Doubly linked list in data structure using C Program
  • Insertion in doubly linked list data structure Using C Program
  • Deletion in doubly linked list data structure Using C Program

Copyright © 2021  programminginc.net