Experiment 8
Experiment 8
1. Display:
➢ Display function:
▪ Write a function named display which is used to display the
linkedist elements. It will be accessed by using for loop,
iterating from NULL to the next node of the linked list.
void display(struct Student *head);
2. Insert:
➢ Insert function:
▪ Write a structure named insert which is used to add a node
into the linked list by taking an input of data needed. struct
Student * insert(struct Student *head, int rollnumber, char
name[100], int age)
3. Delete:
➢ Delete function:
▪ Write a structure named delete which is used to remove a
node from the linked list.
struct Student * Delete(struct Student *head, int rollnumber)
4. Update:
➢ Update function:
▪ Write a function named update which is used to update the
data of the node in the linked list.
void update(struct Student *head, int rollnumber)
❖ Main Function:
• Input all the required details from the user.
• Input the operation to be done by the user.
• Call the operation to be performed.
• By this check various linked list operation.
CODE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Student
char name[50];
rollNumber; struct
Student* next;
};
exit(1);
strcpy(newStudent->name, name);
newStudent->age = age;
newStudent->rollNumber = rollNumber;
newStudent->next = NULL;
return newStudent;
void insertStudent(struct Student** head, char name[], int age, int rollNumber)
{
struct Student* newStudent = createStudent(name, age,
if (current->rollNumber == rollNumber)
if (prev != NULL)
prev->next = current->next;
else
*head = current->next;
free(current);
rollNumber);
return;
prev = current;
current = current->next;
}
if (head == NULL)
return;
printf("List of Students:\n");
head = NULL;
displayStudents(head);
deleteStudent(&head, 102);
displayStudents(head);
return 0;
OUTPUT