print reverse of a number
Answers
Answered by
0
Answer:
Reverse number C program using recursion
#include <stdio.h>
long reverse(long);
int main()
{
long n, r;
scanf("%ld", &n);
r = reverse(n);
printf("%ld\n", r);
return 0;
}
long reverse(long n) {
static long r = 0;
if (n == 0)
return 0;
r = r * 10;
r = r + n % 10;
reverse(n/10);
return r;
}
To reverse or invert large numbers, use long data type or long long data type if your compiler supports it.
For numbers which we can't store in built-in datatypes, use a string or some other data structure.
Explanation:
please mark this as brainliest
Similar questions