Reverse Number Program in C Last Updated : 28 May, 2025 Comments Improve Suggest changes Like Article Like Report The reverse of a number of means reversing the order of digits of a number. In this article, we will learn how to reverse the digits of a number in C language. Example:Input: 12354Output: 45321Explanation: The number 12354 when reversed gives 45321Input: 623Output: 326Explanation: The number 623 when reversed gives 326. Reverse a Number in CThe simplest method to reverse a string is by extracting its digits one by one using (%) modulo and (/) division operator and form the number by rearrange them in the reverse. C #include <stdio.h> // Iterative function to // reverse digits of num int reverseDigits(int num) { int rev_num = 0; while (num > 0) { rev_num = rev_num * 10 + num % 10; num = num / 10; } return rev_num; } int main() { int num = 4562; printf("Given number: %d\n", num); printf("Revers of the number: %d", reverseDigits(num)); getchar(); return 0; } OutputReverse of no. is 2654ExplanationThe above program use a while loop to iterate until the value of num becomes 0. Inside the loop, the last digit of num is extracted using the modulo operator (num % 10). This digit is then added to rev_num after multiplying it by 10, which means the existing digits of rev_num are shifted one place to the left.The value of num is updated by dividing it by 10, (num = num / 10). This removes the last digit of num in each iteration, and terminates the loop when num becomes 0.num = 4562 rev_num = 0rev_num = rev_num *10 + num%10 = 2 num = num/10 = 456rev_num = rev_num *10 + num%10 = 20 + 6 = 26 num = num/10 = 45rev_num = rev_num *10 + num%10 = 260 + 5 = 265 num = num/10 = 4rev_num = rev_num *10 + num%10 = 2650 + 4 = 2654 num = num/10 = 0 Comment More infoAdvertise with us Next Article Reverse Number Program in C kartik Follow Improve Article Tags : C Programs C Language C Basic Programs Similar Reads Palindrome Number Program in C Palindrome numbers are those numbers that remain the same even after reversing the order of their digits. In this article, we will learn how to check whether the given number is a palindrome number using C program.ExamplesInput: 121Output: YesExplanation: The number 121 remains the same when its dig 3 min read C Program to Swap Two Numbers Swapping two numbers means exchanging their values. In this article, we will learn how to swap values of two numbers in a C program.The easiest method to swap two numbers is to use a temporary variable. First, we assign the value of first variable to temporary variable, then assign the value of seco 2 min read C Program To Reverse Words In A Given String Example: Let the input string be "i like this program very much". The function should change the string to "much very program this like i" Examples:Â Input: s = "geeks quiz practice code"Â Output: s = "code practice quiz geeks" Input: s = "getting good at coding needs a lot of practice"Â Output: s = " 3 min read C# Program To Reverse Words In A Given String Example: Let the input string be "i like this program very much". The function should change the string to "much very program this like i" Examples: Input: s = "geeks quiz practice code" Output: s = "code practice quiz geeks" Input: s = "getting good at coding needs a lot of practice" Output: s = "p 4 min read C Program To Print Reverse Floyd's Pattern The Reverse Floyd's Triangle Pattern prints numbers or characters in reverse order, starting with the largest at the top and decreasing as the rows progress. Basically, it is Floyd's triangle that starts with the largest number and ends with 1. In this article, we will learn how to print the Reverse 2 min read C Program to reverse the digits of a number using recursion Given an integer N, the task is to reverse the digits of given integer using recursion. Examples: Input: N = 123Output: 321Explanation:The reverse of the given number is 321. Input: N = 12532Output: 23521Explanation:The reverse of the given number is 23521. Approach: Follow the steps below to solve 2 min read Your First C Program Like in most of the programming languages, program to write the text "Hello, World!" is treated as the first program to learn in C. This step-by-step guide shows you how to create and run your first C program.Table of ContentSetting Up Your EnvironmentCreating a Source Code FileNavigating to the Sou 4 min read C Program to Traverse an Array in Reverse Write a C program to traverse a given array in reverse order that contains N elements.ExamplesInput: arr[] = {2, -1, 5, 6, 0, -3}Output: -3 0 6 5 -1 2Input: arr[] = {4, 0, -2, -9, -7, 1}Output: 1 -7 -9 -2 0 4Different Ways to Traverse an Array in Reverse Order in CWe can traverse/print the array in 2 min read C Programs To learn anything effectively, practicing and solving problems is essential. To help you master C programming, we have compiled over 100 C programming examples across various categories, including basic C programs, Fibonacci series, strings, arrays, base conversions, pattern printing, pointers, and 8 min read C Hello World Program The âHello Worldâ program is the first step towards learning any programming language. It is also one of the simplest programs that is used to introduce aspiring programmers to the programming language. It typically outputs the text "Hello, World!" to the console screen.C Program to Print "Hello Wor 1 min read Like