Computer Science, asked by rajputsr84891, 1 year ago

Write an algorithm for reversing a number

Answers

Answered by fabuco
1

#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;

}

Similar questions