4. (E) Write a program to find the reverse of a number.

4. (E) Write a program to find the reverse of a number.
Write a program to find the reverse of a number.


#include <stdio.h>
int main()
{
int n, reversedNumber = 0, remainder;
printf("Enter an integer: ");
scanf("%d", &n);
while(n != 0)
{
remainder = n%10;
reversedNumber = reversedNumber*10 + remainder;
n /= 10;
}
printf("Reversed Number = %d",reversedNumber);
return 0;
}
4. (E) Write a program to find the reverse of a number. 4. (E) Write a program to find the reverse of a number. Reviewed by admin on December 23, 2019 Rating: 5

No comments:

Powered by Blogger.