#include <stdio.h>
void main()
{
long num, rev = 0, temp, digit;
printf(“Enter the number\n”); /*For better programming,choose ‘long int’ */
scanf(“%ld”, &num);
temp = num;
while(num > 0)
{
digit = num % 10;
rev = rev * 10 + digit;
num /= 10;
}
printf(“Given number = %ld\n”, temp);
printf(“Its reverse is = %ld\n”, rev);
}
/* —————————
Output
Enter the number
123456
Given number = 123456
Its reverse is = 654321
——————————*/
Not Satisfied ? Just search & get the result
Related posts:
- C program to reverse a given integer number and check whether it is a palindrome. Output the given numbers with suitable message
- Sample – Program to enter an integer and print its total value based on the formula ‘x – 1/3!x3 + 1/5!x5 – 1/7!x7 + 1/9!x9′.
- C program to check whether a given number is prime or not and output the given number with suitable message
- C program to convert the given binary number into decimal
- C program to check whether a given integer number is positive or negative
