Returns the positive integer that you get when you reverse the digitsof parameter n

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tousifrad
    New Member
    • Sep 2013
    • 1

    Returns the positive integer that you get when you reverse the digitsof parameter n

    Code:
    #include <iostream>
    using namespace std;
    
    int reverse(int n);
    
    int main()
    {
        int number;
        int n;
    
        cout << " Enter number to reverse." << endl;
        cin >> number;
        cout << reverse(number % 10,0);
    
        return 0;
    }//end main
    
    int reverse(int number,int n)
    {
    
        if(n < 10)
        {
            return n;
        }
        else
        {
            return reverse(number/10,n);
        }
    }
    Last edited by weaknessforcats; Sep 8 '13, 02:43 PM. Reason: added code tags
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    You don't say what your question is, but I am guessing it's why this won't compile:

    Code:
    int reverse(int n);
     
    int main()
    {
    etc...
    You reverse function has two arguments but your prototype above shows only one argument. When the compiler sees you call reverse with two arguments, it generates a "function does not exist" message.

    Comment

    Working...