Computersnyou

C Programming–Write a C Program to Reverse a Number

Posted on  6/14/2012
# include
# include

int main()
{
  long int num,revnum=0,digit;

    printf(“nntttEnter a Number :”);
    scanf(“%ld”,#);

  while(num>0)
  {


     digit = num%10;
     revnum = revnum*10 + digit;
     num = num/10;
  }

  printf(“nntttThe Reversed Number :%ld”,revnum);
  return 0;
}

Output
revnum

If you have any query, then do leave us a comment.Thanks!!!


  • Home
  • About