Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have an error but i can\'t correct it #include <iostream> using namespace std;

ID: 2292466 • Letter: I

Question

I have an error but i can't correct it

#include <iostream>

using namespace       std;

long reverse (long       num, long   equation,long reverse = 0);

int       main()

{

      

       long       num, reverse = 0;

       cout << "Enter       the       num:       ";

       cin >> num;

       cout << "Reverse       num       is       =       "

              << reverse << endl;

       return       0;

}

long reverse(long       num, long equation, long reverse = 0)

{

       while (num)

       {

              equation = num % 10;

              reverse = (reverse *

                     10) + equation;

              num = num / 10;

              return reverse;

       }

}

Explanation / Answer

#include <iostream>

using namespace std;

long reverse (long num);

int main ()
{
   long num;

   cout << "Enter a number ::::: ";
   cin >> num;
   cout << "Reverse of entered number is ::::: " << reverse(num) << endl;

   return 0;
}

long reverse (long num)
{
   long equation, reverse = 0;
   while(num)
   {
   equation = num % 10;
   reverse = (reverse*10) + equation;
   num = num/10;
   }   
   return reverse;
}
/**************** OUTPUT OF PROGRAM **************
Enter a number ::::: 1234567809
Reverse of entered number is ::::: 9087654321
*************************************************/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote