  Problem statement: Given a number, delete the first occurrence of that number in the linked list.

 Iterative Solution 1) Find the previous node of the node that is to be deleted. 2) Assign the next of the previous node. 3) Free(temp).
```/*C code to delete an node from the Linked List */
#include <stdio.h>
#include <stdlib.h>

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

NODE *newNode(int key)
{
NODE *temp = (NODE *)malloc(sizeof(NODE));
temp->data = key;
temp->next = NULL;
return temp;
}

{
if (temp != NULL && temp->data == key)
{
printf("%d is deleted from the Linked List!\n", key);
free(temp);
}
while (temp != NULL && temp->data != key)
{
prev = temp;
temp = temp->next;
}
if (temp == NULL)
{
printf("%d is not present in the Linked List!\n", key);
}
prev->next = temp->next;
printf("%d is deleted from the Linked List!\n", key);
free(temp);
}

void printList()
{
if (temp == NULL)
{
printf("List is empty!\n");
return;
}
while (temp != NULL)
{
printf("%d--> ", temp->data);
temp = temp->next;
}
printf("NULL\n");
}

int main()
{
printList();
int key;
printf("Enter the key to delete\t");
scanf("%d", &key);