0% found this document useful (0 votes)
8 views1 page

SLL Reverse

Uploaded by

om.op3435
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

SLL Reverse

Uploaded by

om.op3435
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <stdio.

h>
#include <stdlib.h>

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

void LinkedListTraversal(struct node *ptr)


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

int main()
{
struct node *first;
struct node *second;
struct node *third;
struct node *fourth;

first = (struct node *)malloc(sizeof(struct node));


second = (struct node *)malloc(sizeof(struct node));
third = (struct node *)malloc(sizeof(struct node));
fourth = (struct node *)malloc(sizeof(struct node));

first->data = 7;
first->next = second;

second->data = 57;
second->next = third;

third->data = 34;
third->next = fourth;

fourth->data = 29;
fourth->next = NULL;

printf("Linked List Before Insertion \n");


LinkedListTraversal(first);
printf("Linked List after reverse\n");
LinkedListTraversal(first);
return 0;
}

You might also like