[Solved] Editing a List Program in C


Just change to line

if (List == NULL || List->data < d)

to

if (List == NULL || List->data > d)

And change the line

while ((ptr->next != NULL) && (ptr->next->data>d)){

to

while ((ptr->next != NULL) && (ptr->next->data<d)){

And you have not added 0 check.Please add that, rest is fine. For this modify the for loop with this one

//printf("How many numbers are you going to enter? ");
//scanf("%d", &n);
for (;;)
{
    printf("\nEnter a number: ");
    scanf("%d", &a);
    if(a == 0)
       break;
    Add(List, a);
}

3

solved Editing a List Program in C