Friday, October 16, 2015

Reverse Number in C - Working Code

#include<stdio.h>
#include<conio.h>
void main()
{
   int n, reverse=0;
   clrscr();
   printf("Enter any 4 numbers to reverse\n");
   scanf("%d", &n);
   while(n != 0)
   {
      reverse = reverse*10;
      reverse = reverse+n%10;
      n = n/10;
   }
   printf("Reverse of entered number is = %d\n",reverse);
   getch();
}

To Compile Press Alt+f9 
To Run Press Ctrl+f9

Output: 



No comments:

Post a Comment