Skip to content

Commit

Permalink
Create Reverse_Integer.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanika2103 authored Oct 28, 2022
1 parent 3cf1013 commit 621be0a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions solutions/Reverse_Integer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <iostream>

using namespace std;
int rev;
int rem;
int reverseInt(int n) {
if (n == 0) return 0;
rem = n % 10;
rev = rev * 10 + rem ;
reverseInt(n / 10);

return rev;
}
int main()
{
int n;
cin >> n;
cout << reverseInt(n);

return 0;
}

0 comments on commit 621be0a

Please sign in to comment.