Reverse a Linked List” is one of the favourite technical interview problem based on Linked List. Here, we are given a linked list and our task is to reverse the given list.

NOTE: We need to reverse the order of the nodes, not reverse the data value of nodes.

The steps required to reverse a linked list are as follows:

1. Initialize resultant list as NULL.
2. Traverse the complete list. While traversing the linked list, for every node encountered, remove that node, and add that node to the beginning of resultant list.

#### C++ Program to reverse a linked list is as follows:

```/* C++ Program to Reverse a Linked List */
#include<bits/stdc++.h>
using namespace std;

/* Strcuture of the Node of Linked List */
typedef struct node
{
int data;
struct node *next;
}Node;

/* Function to Insert Nodes in the Linked List */
{
/* Creating a new node */
Node *new_node;
new_node = (struct node*)malloc(sizeof(struct node));
new_node->data = ele;
new_node->next = NULL;

/* Check whether the linked list is empty or not */

/* If Linked List is Empty */
{
return;
}

/*
If Linked List is not empty, then traverse the complete linked list and
pointer of last node of the linked list will point to the new node of
*/
Node *temp = NULL;
while(temp->next != NULL)
temp=temp->next;
temp->next = new_node;
}

/* Function to Reverse a Linked List */
{
Node *res = NULL;

/*
Traverse the complete Linked List and remove nodes one-by-one from the linked List
*/
while(temp!=NULL)
{
Node *p = temp;
temp = temp->next;
p->next = NULL;
p->next = res;
res = p;
}

}

/* Function to print the Linked List */
{
while(temp!=NULL)
{
cout<<temp->data<<" ";
temp=temp->next;
}
cout<<endl;
}
int main()
{
/* Insert Some Nodes in the Linked List */
/* Reverse a Linked List */
```OUTPUT: