#include<stdio.h>
#include<conio.h>
main()
{
int n, reverse=0, rem; //declaration of variables.
clrscr(); // It clears the screen.
printf(“Enter a number: “);
scanf(“%d”, &n);
while(n!=0)
{
rem=n%10;
reverse=reverse*10+rem;
n/=10;
}
printf(“Reversed Number: %d”,reverse);
getch(); // It reads a character from the keyword.
}
Vishalini.R Answered question June 26, 2023
Understanding a C Program’s Algorithm to Reverse a Number
We’ll declare two int variables: ‘Number’ will retain the number to be reversed, and ‘Reversed_Number,’ which will be initialized to 0, will hold the resultant reversed number.
Now we’ll apply the formula Reversed_Number = Reversed_Number*10 + Number%10 to find the inverse of a number.
Vishalini.R Answered question June 26, 2023
