Reverse digits of a number

Algorithm

Input   An integer  
Output  Reverse of number  
complexity  O(d) where d is the number of digits in the number  
  
Digitsreverse(num)  
1 while (num>0) then  
2   digit =num%10;  
3   print digit;  
4   num= num/10;  

Algorithm Description

This algorithm takes an integer and reverses its digits. It keeps on dividing it by 10 to get the individual digit of the number from the LSD and then writes it in reverse order. 

C Code

//To Find the reverse of a number
//Input : Any positive integer

#include
#include
int main()
{
    int num,rem;
    printf("Enter a number ");
    scanf("%d",&num);
    printf("The reverse of %d is :",num);
    while(num>0)
    {
                rem=num%10;
                printf("%d",rem);
                num=num/10;         
    }
}