Discussion Forums

New User? Please read instructions!

Need C program to reverse a given number  

  RSS

thiyagarajan
Eminent Member
Joined:10 months  ago
Posts: 26
27/01/2017 9:35 am  

C program to reverse a given number


ReplyQuote
admin
Eminent Member Admin
Joined:5 years  ago
Posts: 26
31/01/2017 11:25 am  

Hi Thiyagarajan, Below C program will reverse a given number.

 

#include <stdio.h> 

int main()

{

   int n, rev = 0;

   printf("Please enter a number to reverse\n");

   scanf(""%d"",&n);

 

   while (n != 0)

   {

      rev = rev * 10;

      rev = rev + n%10;

      n = n/10;

   }

 

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

   return 0;

}


ReplyQuote
  
Working

Please Login or Register






Share this website !!!
Facebook Twitter Linkedin