Reverse A Number C Program

C Program To Reverse a Number using Loops

Learn How To Reverse A Number in C Programming Language. It is important that we should know How A For Loop Works before getting further with this C Program Code.

To Reverse the Digits of an Integer, we need to Extract every End Digit using Modulus Operator and then store it in a Sum variable. Then, keep on adding the other digits to the Sum variable.


Reverse of 1234 = 4321

Method 1: Reverse an Integer with While Loop in C Programming

Method 2: Reverse a Number using For Loop in C Programming

Method 3: C Program Code To Reverse a Number using Function

Method 4: C Code To Reverse an Integer using Recursion


Learn How To Reverse A Number in C Programming Language

In case you get any Compilation Errors with this C Program To Reverse the Digits of a Number or you have any doubt about it, mention it in the Comment Section.

Recommended Programs
C Program To Find Sum of First Natural Numbers
Print Hello World without using Semicolon in C Programming Language
C Program To Search The Smallest Digit in a Number
Find Arithmetic Progression in C Programming
C Program To Convert Hexadecimal Value To Binary Value
C Program To Find Armstrong Number

Tushar Soni

I am Tushar Soni, Co - Founder of CodingAlpha. I am a computer science student from India and passionate about Web Development and Programming. Connect with me on Facebook | LinkedIn | Google Plus

9 thoughts on “Reverse A Number C Program

  • July 21, 2016 at 2:43 pm

    how can I display reverse of 100,200,2000…etc as 001,002,0002…/etc

    is there any code for it

  • July 31, 2016 at 10:05 pm

    I think the same method will work fine to display reverse of 100, 200 and such numbers.

  • August 20, 2016 at 4:13 pm

    Thanks for so many methods. This has helped me to.understand the difference between while loop and for loop so efficiently. Reverse Number C Program is also used as a parr of Palindrome Number if I am not wrong.

  • August 20, 2016 at 4:14 pm

    Is there any library function to reverse an integer in C Programming? It would be then so easy.

    • September 5, 2016 at 12:19 pm

      For Reversing a String, there is a function strrev(). I am not sure about Reversing Function for Integers. However, you can check the above function. Copy it into a new header file and include it in your program.

  • September 8, 2016 at 1:39 pm

    This is fucking amazing man! So many methods just to reverse an integer?? Thanks!!! 🙂

  • September 13, 2016 at 10:17 pm

    For (; num>0; num = num/10)
    This is something that I found. I guess it meams that we can skip a part of the For loop without getting amh compilation error.

  • September 13, 2016 at 11:03 pm

    Thank you so much for the explanation of how to reverse a number in c programming.

  • October 14, 2016 at 9:49 am

    In your second method to reverse an integer, the for loop can be modified to represent a normal for loop in the following way:
    for(temp = num; num > 0; num = num/10;)
    rem = num%10;
    sum = (sum*10) + rem;


Join The Discussion