C Programming Tutorial

Advertisements

Write program to show reverse of a number in c



       #include<stdio.h>
       #include<conio.h>
       void main()
       {
              int a,num,rev=0; 
              clrscr();

              printf("\nEnter any number : "); 
              scanf("%d",&num); 

              while(num>0)
              {
                   m = num % 10;                   
                   rev = (rev*10) + m;
                   num = num / 10;
                }
              
              printf("\nThe Reverse is : %d",rev);      

              getch();
       }

   Output : 

              Enter any number : 4527 
              The Reverse is : 7254




Advertisement