Write a program to reverse a number. e.g.: if the is 876 then output will be 678

#include<stdio.h>

int main()

   {

      Int   n, r, temp;

      printf( "Enter an integer number: " );

      scanf( "%d" , &n);

      temp=n;

      r=0;

      while(n>0)

        {

          r=r*10 + n%10;

          n=n/10;

         }

      printf( "\nReverse of %d = %d" , temp, r);

      return 0;

 }

No comments:

Post a Comment