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
- C Program to Find Maximum and Minimum Numbers
- C Program to Read a Text File
- C Program to Convert Decimal to Hexadecimal
- C Program to Convert Decimal to Binary
- C Program to Convert Celsius to Fahrenheit
- C Program To Find Absolute Value
- Ternary Operator Program in C
- C Program For Addition Table Using For Loop
- Denomination Program in C
- C Program to Print Multiplication Table
- C Program Array with Example
- Binary Search in C Program Using Recursion
- Bubble Sort in C Using Pointers
- Bubble Sort Program in C Using Recursion
- Bubble Sort Program in C Using Array
- Bubble Sort Program in C Using Function
- Bubble Sort Program in C Using Linked List
- Stack Push Pop Program in C Using Arrays
- Factorial Program in C Using Pointers
- Factorial Program in C Using While Loop