1 year ago

#352214

test-img

Pintu Batesar

some sun time errors in c

full code is this: Insertion in linked list Please make it like it run smoothly then After i will debug on basis of my algorithms.

#include <stdio.h>
#include <stdlib.h>

#define  null 0
struct node
{
  int data;
  struct  node *next;
};
int insertion(struct node**,struct node**,int,int);

int main()
{
  struct  node *head=null,*tail=null,*next=null;
  int pos,result,input;
  head->next=null;
  int choice;
  while(1)
  {
   printf ("choices:\n");
   printf ("1:insertion\n");
   printf ("2:deletion");
   printf ("0:exit\n");
   scanf("%d",&choice);
   switch(choice)
   {
     case 1:
        
        printf("Enter position for insertion:");
        scanf("%d",&pos );
        printf("Enter element to insert:");
        scanf("%d",&input);
        printf("linked  list before insertion:");
        while(head->next!=null)
       {
        printf ("%d->",head->data);
        head=head->next;
       }
       result=insertion(&head,&tail,pos,input);
       if(result==-1)
       printf ("Insertion failed!!");
       else
      {
        printf ("Insertion success😎\n");
        printf ("linked list after insertion:");
        while(head->next!=null)
        {
         printf ("%d->",head->data);
         head=head->next;
        }
      }
       break;
  // case 2:
      
   case 0:
       exit(0);
   default:
       printf ("Wrong choice\n");
   }
   return 0;
 }
}
int  insertion(struct node** head,struct node** tail,int pos,int input)

its showing some Run error.

i have deleted function definition but still i think errors is in the given piece of code only.

c

compiler-errors

function-call

function-declaration

function-prototypes

0 Answers

Your Answer

Accepted video resources