reverse a integer by recursion

how to do it using recursion?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
using namespace std;

int f(int n)
{
	string s;
	int a;
	while(n>0)
	{
		a = n%10;
		s+= to_string(a);
		n/=10;				
	}	 
	int b= stoi(s)
	return b;
}


int main()
{	
	int i = 4389; 
	cout << f(i);
}
Topic archived. No new replies allowed.