Explore BrainMass
Share

Reversing integer using recursion

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

I need a recursive function that accepts an integer and returns its reverse.

for example

int reverse( int n );
int main()
{
int n;
n = reverse (123) ; // this returns 321

}

I can do this easily without recursion but I have to use recursion.
Thank you.

© BrainMass Inc. brainmass.com March 21, 2019, 4:18 pm ad1c9bdddf
https://brainmass.com/computer-science/cpp/reversing-integer-using-recursion-181080

Solution Preview

#include "stdafx.h"
#include <iostream>

using namespace std;

static int reverse (int n) ;
static ...

Solution Summary

The expert examines reversing integers using recursion.

$2.19