You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
programming-examples/c/Basic/C Program to Reverse a Give...

20 lines
463 B
C

/*
* C program to accept an integer and reverse it
*/
#include <stdio.h>
void main()
{
long num, reverse = 0, temp, remainder;
printf("Enter the number\n");
scanf("%ld", &num);
temp = num;
while (num > 0)
{
remainder = num % 10;
reverse = reverse * 10 + remainder;
num /= 10;
}
printf("Given number = %ld\n", temp);
printf("Its reverse is = %ld\n", reverse);
}