C Program To Reverse A Number

C Program To Reverse A Number. If you are looking for c program to reverse digits of a number, this c programming tutorial will help you to learn and code how to write source code.

C Program To Reverse A Number

Learn how to write a c Program to reverse a number. Writing reverse a number program in C can be done using various techniques but here in this program, we show how to write a c program to reverse digits in a number using while loop in a proper way. Happy coding.

Related Programming Tutorials: 

C Program For Palindrome Number

C Program For Palindrome String

C Program To Reverse A Number Source Code

You can copy paste the below C Program to reverse a number using while loop, in c compiler to check how the source code work.

Example Source Code:

/* C Program To Reverse A Number - ReverseNumber.C */

#include <stdio.h>
int main()
{
 //variable declaration
 int n, reversedNumber = 0, remainder;

 //Asking your to enter a number to reverse
 printf("Please Enter a Number: ");
 scanf("%d", &n); //Reading user entered number

//Logic to reverse a number using while loop
 while(n != 0)
 {
   remainder = n%10;
   reversedNumber = reversedNumber*10 + remainder;
   n /= 10;
 }
 //Printing reversed Number
 printf("Reversed Number is = %d", reversedNumber);
 return 0;
}

C Program For Reverse A Number Output

When you compile and run the above c program for reverse a number, your C compiler asks you to enter the positive integer to reverse it. After entering the number, C compiler will reverse it and display.

Output:

Please Enter a Number: 56789

Reversed Number is = 98765

C PROGRAMMING EXAMPLES

  1. C Program to Find Maximum and Minimum Numbers
  2. C Program to Read a Text File
  3. C Program to Convert Decimal to Hexadecimal
  4. C Program to Convert Decimal to Binary
  5. C Program to Convert Celsius to Fahrenheit
  6. C Program To Find Absolute Value
  7. Ternary Operator Program in C
  8. C Program For Addition Table Using For Loop
  9. Denomination Program in C
  10. C Program to Print Multiplication Table 
  11. C Program Array with Example
  12. Binary Search in C Program Using Recursion
  13. Bubble Sort in C Using Pointers
  14. Bubble Sort Program in C Using Recursion
  15. Bubble Sort Program in C Using Array
  16. Bubble Sort Program in C Using Function
  17. Bubble Sort Program in C Using Linked List
  18. Stack Push Pop Program in C Using Arrays
  19. Factorial Program in C Using Pointers
  20. Factorial Program in C Using While Loop

Leave a Comment