Skip to main content

Posts

C program in data structure to make circular linked list

#include<stdio.h> #include<conio.h> #include<process.h> void create(); void display(); void addbeg(); void addlast(); struct node {  int info;  struct node *link; }*start=NULL; void main() {  int n;  clrscr();  while(1)  {   printf("\n **menu**\n");   printf("\n 1. to create list \n 2. to display list");   printf("\n 3. to add node at beginning of linked list");   printf("\n 4. to add node at the last of linked list");   printf("\n 5. exit");   printf("\n Enter your choice:-");   scanf("%d",&n);   switch(n)   {    case 1 : create();    break;    case 2 : display();    break;    case 3 : addbeg();    break;    case 4 : addlast();    break;    case 5 : exit(0);   }  }  getch(); } void create() {  struct node *temp,*q;  int x; ...

C program in data structure to find the intersection between two linked list

#include<stdio.h> #include<conio.h> #include<process.h> #include<stdlib.h> struct node {  int info;  struct node *link; }*start1=NULL,*start2=NULL; void main() {  struct node *temp,*q,*p;  int n,i,x,f=0;  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;   } ...