Skip to main content

Posts

C program in data structure to reverse the singly linked list

/* Reverse the singly linked list */ #include<stdio.h> #include<conio.h> #include<process.h> struct node {  int info;  struct node *link; }*start=NULL; void main() {  struct node *temp,*q,*p,*t;  int n,i,x;  clrscr();  printf("\n Enter How many number:-");  scanf("%d",&n);  for(i=0;i<n;i++)  {   temp=(struct node*)malloc(sizeof(struct node));   if(temp==NULL)   {    printf("\n Insufficient memory");    getch();    exit(0);   }   printf("\n Enter number:-");   scanf("%d",&x);   temp->info=x;   temp->link=NULL;   if(start==NULL)   {    start=temp;   }   else   {    q=start;    while(q->link!=NULL)    {      q=q->link;    }    q->link=temp;   }  }  t=NULL;  for(i=0;i<...

C program in data structure for concatenate two linked list

#include<stdio.h> #include<conio.h> #include<process.h> #include<string.h> struct node {  int info;  struct node *link; }*start1=NULL,*start2; void main() {  struct node *temp,*q;  int n,i,x;  clrscr();  printf("\n First linked list");  printf("\n Enter How many number:-");  scanf("%d",&n);  for(i=0;i<n;i++)  {   temp=(struct node*)malloc(sizeof(struct node));   if(temp==NULL)   {    printf("\n Insufficient memory");    getch();    exit(0);   }   printf("\n Enter number:-");   scanf("%d",&x);   temp->info=x;   temp->link=NULL;   if(start1==NULL)   {    start1=temp;   }   else   {    q=start1;    while(q->link!=NULL)    {      q=q->link;    }    q->link=temp;   }  } ...