Saturday, 28 April 2012

Reverse a number

                 C System to opposite a variety :- The offer opposite the variety joined by the individual and then printing the changed variety on the screen. For example if individual get into 123 as feedback then 321 is produced as result. In our program we use modulus(%) owner to obtain the numbers of a variety. To change variety look at it and write it from other or the result of value is a variety acquired by writing unique variety from right to left. To opposite thousands use lengthy information kind or lengthy long information kind if your compiler can handle it, if you still have thousands then use post or other information structure.



#include<stdio.h>
#include<conio.h>

void main()
{
   int n, reverse = 0;

   printf("Enter a number to reverse\n");
   scanf("%d",&n);

   while( n != 0 )
   {
      reverese = reverese * 10;
      reverese = reverese + n%10;
      n = n/10;
   }

   printf("Reverse of enter No. is = %d\n", reverse);

   getch();
}

output:-

Enter the number to reverse
1234
reverse of entered number is=4321

No comments:

Post a Comment