Computer Science, asked by jayakrishnanmartin, 5 months ago

a python function to reverse a number from the given number

Answers

Answered by Anonymous
2

\huge\fcolorbox{black}{lime}{AnsweR:}

#include <bits/stdc++.h>  

 

using namespace std;  

/* Iterative function to reverse digits of num*/

int reversDigits(int num)  

{  

   int rev_num = 0;  

   while(num > 0)  

   {  

       rev_num = rev_num*10 + num%10;  

       num = num/10;  

   }  

   return rev_num;  

}  

 

/*Driver program to test reversDigits*/

int main()  

{  

   int num = 4562;  

   cout << "Reverse of no. is "

        << reversDigits(num);  

   getchar();  

   return 0;

}

\large\bold{\bigstar\:Ayush\:Mehra\:\bigstar}

Similar questions