C Program to Print the reverse of a given number


#include<stdio.h>

main()

{

  int dummy,n,rev=0,x;

  printf("Enter a number\n");

  scanf("%d",&n);

  dummy=n;

  while(n>0)

  {

    x=n%10;

    rev=rev*10+x;

    n=n/10;

  }

  printf("The reverse of %d is %d\n",dummy,rev);

}

Output:-
Enter a number
234
The reverse of 234 is 432

Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post