# C Program to Reverse a Singly Linked List using Iteration

Write a C program to reverse a singly linked list. Given a linked list, write a method to reverse a singly linked list. In this tutorial, we are going to write a code to reverse a linked list using an iterative approach.

There are two ways to reverse a linked list. We can reverse a linked list using an iterative approach or we can reverse a linked list using recursion. Both approaches are very important in terms of interviews. So make you understand the concept and practice it very well.

C Program to Reverse a linked list using recursion

Also, we are using an iterative approach to solve this problem. If you are not familiar with iterative and recursive approach then check my previous tutorial on Recursion vs iteration.

## Algorithm to Reverse a Singly Linked List

C program to count number of nodes in a linked list

2. Declare a three-pointers prev, next and current of a node type. The current pointer points to head. Using current pointer traverse a linked list until current node is not null. Change the links (or pointer to reverse a linked list).

Subscribe Our Tutorials

The time complexity to reverse a singly linked list is O(n).

Program to Reverse a Linked List

## C Program to Reverse a Singly Linked List

We have discussed the algorithm to reverse a linked list. Let’s write a c code to implement an algorithm to reverse a singly linked list.

Output :

Books on Data Structures

I have tried my best to explain how to reverse a singly linked list in a very simple and easy way. If you still have any doubt and you want to share another approach with our readers then you can let us know through your comments.