Question

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

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;

       }

}

Homework Answers

Answer #1

#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
*************************************************/

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Rewrite the following program using switch statements. //Set 7.1 #include <iostream> #include <iomanip> using namespace std;...
Rewrite the following program using switch statements. //Set 7.1 #include <iostream> #include <iomanip> using namespace std; int main() {        int x;        cout << "Selection option " << endl;        cin >> x;        if (x == 1)               cout << "You select option 1" << endl;        else if (x >= 2 || x <= 4)               cout << "You select options 2 or 3 or 4" << endl;               else if (x == 10)               cout << "You select option 10" << endl;               else...
Please write variables and program plan (pseudocode) of the C++ programming below: #include <iostream> #include <cmath>...
Please write variables and program plan (pseudocode) of the C++ programming below: #include <iostream> #include <cmath> using namespace std; void divisors(int num); int main () {    char repeat;    int num;       while (repeat !='n')    {        cout << "Enter a number: ";        cin >> num;        divisors(num);        cout << "Continue? (y or n): ";        cin >> repeat;    }    return 0; } void divisors(int num) {   ...
How to trace a c++ program by hand #include<iostream> using namespace std;    class Test {...
How to trace a c++ program by hand #include<iostream> using namespace std;    class Test {     int value; public:     Test(int v); };    Test::Test(int v) {     value = v; }    int main() {     Test t[100];     return 0; } _______________ #include <iostream> using namespace std; int main() { int i,j; for (i=1; i<=3; i++) { for(j=1; j<=i; j++ ) { cout<<"*"; } cout << "\n";   } return 0; }
//Calculate the even parity for letters, (A, Z, D, a). #include <iostream> #include <bitset> using namespace...
//Calculate the even parity for letters, (A, Z, D, a). #include <iostream> #include <bitset> using namespace std; int main() { char c; int bitCounts, pBit;; while (cin>>c){ //ctrl-Z to stop bitset<8> bs(c); cout<<bs<<endl; bitCounts = bs.count(); pBit = bitCounts % 2? 1: 0; cout<<"Even Parity bit: "<<pBit<<endl; } }
Take the following program and translate it into PEP/9 assembly language: #include <iostream> using namespace std;...
Take the following program and translate it into PEP/9 assembly language: #include <iostream> using namespace std; int fib(int n) { int temp; if (n <= 0)    return 0; else if (n <= 2)    return 1; else {    temp = fib(n – 1);    return temp + fib(n-2); } } int main() {    int num;    cout << "Which fibonacci number? ";    cin >> num;    cout << fib(num) << endl;    return 0; } You...
This code it's not working, fix it for me please #include <iostream> using namespace std; class...
This code it's not working, fix it for me please #include <iostream> using namespace std; class People {    string name;    double height; public:    void setName(string name)    {        this->name = name;    }    void setHeight(double height)    {        this->height = height;    }    double getHeight() {        return height;    }    string getName()    {        return name;    } }; int main() {    const int size...
in C++ Need a heap-sort function #include <iostream> #include <stdlib.h> #include <string> using namespace std; void...
in C++ Need a heap-sort function #include <iostream> #include <stdlib.h> #include <string> using namespace std; void MyFunc ( int *array ) { // Your code here ----------------- } int main(int argc,char **argv) { int *Sequence; int arraySize; // Get the size of the sequence cin >> arraySize; // Allocate enough memory to store "arraySize" integers Sequence = new int[arraySize];    // Read in the sequence for ( int i=0; i<arraySize; i++ ) cin >> Sequence[i]; // Run your algorithms to...
Quick sort func in C++ #include <iostream> #include <stdlib.h> #include <string> using namespace std; void MyFunc...
Quick sort func in C++ #include <iostream> #include <stdlib.h> #include <string> using namespace std; void MyFunc ( int *array ) { // Code here } int main(int argc,char **argv) { int *Sequence; int arraySize; // Get the size of the sequence cin >> arraySize; // Allocate enough memory to store "arraySize" integers Sequence = new int[arraySize];    // Read in the sequence for ( int i=0; i<arraySize; i++ ) cin >> Sequence[i]; // Run your algorithms to manipulate the elements...
Analyze the following program and write down the output. # include <iostream> using namespace std;    void...
Analyze the following program and write down the output. # include <iostream> using namespace std;    void modifyArray( int [ ], int );    void modifyElement ( int );      int main( ) {   const int arraySize = 8;   int a[arraySize] = { 2, -2, 10, -3, -1 ,0, 10, -5 };      modifyArray ( a, arraySize);      for ( int i =0; i < arraySize; i++)               cout << a[i] << ‘  ’;         modifyElement ( a[4] );          for ( int i =0; i <...
1. Type in the following program. Compile and run. #include <iostream> using namespace std; int main()...
1. Type in the following program. Compile and run. #include <iostream> using namespace std; int main() { ​cout << "Hello, world." << endl; } Open a Word Document and copy and paste the program and the output. 2. Create a new program: #include <iostream> using namespace std; int main() { ​float num1; ​float num2 ​float avg; ​cout << "Enter two numbers" << endl; ​cin >> num1 >> num2; ​avg = num1 + num2/2; ​cout << "The average is " <<...