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

struct node
{
    int data;
    struct node *next;
};
typedef struct node node;

node* insertFront(node* head, int d);
node* insertBack(node* head, int d);
void print(node* head);
int max(node* head);
int min(node* head);
int locInList(node* head, int x);

int main()
{
    node* head = NULL;
    node* temp = NULL;

    head = malloc(sizeof(node));

    head = insertBack(head, 5); 
    head = insertFront(head, 4);
    head = insertFront(head, 3);
    head = insertBack(head, 6);
    head = insertBack(head, 7);
    print(head);

    printf("\nMax: %d\n", max(head));
    printf("Min: %d\n", min(head));
    printf("locInList 5: %d\n", locInList(head, 5));
    printf("locInList 9: %d\n", locInList(head, 9));    
    return 0;
}

node* insertFront(node* head, int d)
{
    node *tmp = NULL;

    tmp = malloc(sizeof(node));
    tmp->data = d;
    tmp->next = head;
    head = tmp;

    return head;
}

node* insertBack(node* head, int d)
{
    node *ptr;
    ptr->data=d;
    ptr->next = NULL;

    if(head==NULL)
    {
        head->data=d;
        head->next=NULL;
    }
    else
    {
        node *temp=head;
        while(temp->next != NULL)
        {
            temp=temp->next;
        }

        temp->next=ptr;

    }
    return head;
}

void print(node* head)
{
    node *tmp = head;

    while(tmp != NULL)
    {
        printf("%d ", tmp->data);
        tmp = tmp->next;
    }

}

int max (node* head)
{
 int max;
 while (head != NULL)
 {
     if (max > head->data)
     max = head->data;

 }
 return max;
}

int min (node* head)
{
 int min;
 while (head != NULL)
 {
     if (min < head->data)
     min = head->data;

 }
 return min;
}

int locInList(node* head, int x)
{

}

```

I'm having trouble with my InsertBack function, I want to add the value of d to the end of head. 

The current output I'm getting with this code is:

3 4 0 7 7 7 7 7 7 7...repeating

The output should look like this

34567
Max: 7
Min: 3

Any help would be appreciated. I'm also very new to linked lists. So any help would be very appreciated!!