# C Program for Printing reverse of a Linked List without actually reversing

## Reverse printing a Linked List without actually reversing  the Linked List

Here we will learn how to code a C program for Reverse Printing a Linked List, without actually reversing it. This is a pretty simple problem in which we will make a linked list, and instead of printing it in the usual manner we will traverse to the tail of the Linked List, and will print it in the reverse order. Let’s see how to code a program for this problem.

## How do you reverse a Linked List ?

In this program we are not actually reversing a Linked List, but just printing the Linked List backwards, for doing so we will be following the below steps -:

• Step 1 – Take a pointer ptr.
• Step 2 – Check whether the Linked List has nodes or not.
• Step 3 – If the linked list is empty, return 0.
• Step 4 – If the linked list has nodes, move the pointer ahead till it reaches NULL.
• Step 5 – Backtrack and print the data of the nodes

### Algorithm for Reverse Printing a Linked List

• CREATE A FUNCTION DISPLAY
• RETURN 0
• ELSE

## C Program for Reverse printing a Linked List

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

struct node			//code for making a node
{
int data;
struct node *next;
};

void display (struct node *head)	//method for reverse display nodes
{
return;

// print the list after head node

// After everything else is printed, print head
}

int main ()
{
int n, i;
printf ("Enter size of Linked List: ");
scanf ("%d", &n);
for (i = 0; i < n; i++)
{
p = malloc (sizeof (struct node));
printf ("Enter the data: ");
scanf ("%d", &p->data);
p->next = NULL;
else
prev->next = p;
prev = p;
}
return 0;
}
```

### Output

`Enter size of Linked List: 5Enter the data: 1Enter the data: 2Enter the data: 3Enter the data: 4Enter the data: 55 4 3 2 1`

### Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

## Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

## Checkout list of all the video courses in PrepInsta Prime Subscription

• Introduction to Linked List in Data Structure
• Linked List in – C | C++ | Java
• Singly Linked List in – C | C++ | Java
• Insertion in singly Linked List – C | C++ | Java
• Insertion at beginning in singly Linked List  – C | C++Java
• Insertion at nth position in singly Linked List  – C | C++Java
• Insertion at end in singly Linked List  – C | C++Java
• Deletion in singly Linked List  – C | C++Java
• Deletion from beginning in singly linked list : C | C++ | Java
• Deletion from nth position in singly linked list : C | C++ | Java
• Deletion from end in singly linked list : C | C++ | Java
• Reverse a linked list without changing links between nodes (Data reverse only) – C | C++Java
• Linked List Insertion and Deletion – C | C++Java
• Reverse a linked list by changing links between nodes – C | C++Java
• Linked List insertion in the middle – C | C++Java
• Print reverse of a linked list without actually reversing – C |C++ | Java
• Search an element in a linked list – C | C++Java
• Insertion in a Sorted Linked List – C | C++Java
• Delete alternate nodes of a Linked List – C | C++Java
• Find middle of the linked list – C | C++Java
• Reverse a linked list in groups of given size – C | C++Java
• Find kth node from end of the linked list – C | C++Java
• Append the last n nodes of a linked list to the beginning of the list – C | C++Java
• Check whether linked list is palindrome or not – C | C++Java
• Fold a Linked List – C | C++Java
• Insert at a given position – C | C++Java
• Delete at a given position – C | C++Java

• Introduction to Linked List in Data Structure
C | C++ | Java
• Singly Linked List in –
C | C++ | Java
• Insertion in singly Linked List –
C | C++ | Java
• Insertion at beginning in singly Linked List  –
C | C++Java
• Insertion at nth position in singly Linked List  –
C | C++Java
• Insertion at end in singly Linked List  –
C | C++Java
• Deletion in singly Linked List  –
C | C++Java
• Deletion from beginning in singly linked list :
C | C++ | Java
• Deletion from nth position in singly linked list :
C | C++ | Java
• Deletion from end in singly linked list :
C | C++ | Java
• Linked List Insertion and Deletion –
C | C++Java
• Reverse a linked list without changing links between nodes (Data reverse only) –
C | C++Java
C | C++Java
• Print reverse of a linked list without actually reversing –
C |C++Java
• Print reverse of a linked list without actually reversing –
C |C++Java
• Insertion in the middle Singly Linked List –
C | C++Java
• Insertion in a Sorted Linked List –
C | C++Java
• Delete alternate nodes of a Linked List –
C | C++Java
• Find middle of the linked list –
C | C++Java
• Reverse a linked list in groups of given size –
C | C++Java
• Find kth node from end of the linked list –
C | C++Java
• Append the last n nodes of a linked list to the beginning of the list –
C | C++Java
• Check whether linked list is palindrome or not –
C | C++Java
• Fold a Linked List –
C | C++Java
• Insert at given Position –
C | C++Java
• Deletion at given Position –
C | C++Java