Discussion Forums

New User? Please read instructions!

Need C program to reverse a given number  

  RSS

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

C program to reverse a given number


ReplyQuote
admin
Eminent Member
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

Ask your questions or clarify your/others doubts from,

✅ Online Discussion Forums by Fresh2Refresh.com





Share this website !!!
Facebook Twitter Linkedin

Close
We Support JALLIKATTU !!!
We Support JALLIKATTU!
By Fresh2Refresh.com
Show Your Support as well. Thanks!