-
Notifications
You must be signed in to change notification settings - Fork 1
/
Exer9.cpp
46 lines (30 loc) · 916 Bytes
/
Exer9.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
using namespace std;
int reverseDigit(int,int);
int main()
{
int number;
int n;
cout << " Enter the number to reverse." <<endl<<endl;
cin >> number;//Displays the number you want to reverse.
cout<< "The reversed number is"<<endl<<endl;//Gives you the reversed number.
cout << reverseDigit((number* 10+ number % 10)/100, number % 10)<<endl<<endl;
system("pause");
return 0;
}//end main
int reverseDigit(int number, int n = 0)
{
if (number == 0)
{
return n;
}
else
{
int nextdigit = number%10;
int nextprefix = n*10 + nextdigit;
return reverseDigit(number/10 ,nextprefix);
}
// Author: Bryan N. Brizo
// Date: November 23, 2013
// Program description: A function that takes an integer as a parameter and returns the number with its digits reversed.
}