Skip to content

Commit 34ec349

Browse files
committed
Reversing a number in C++
1 parent ac9e851 commit 34ec349

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

problems/reverse of a number.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <iostream>
2+
using namespace std;
3+
int main()
4+
{
5+
int t;
6+
cin>>t;
7+
while(t--)
8+
{
9+
long long int n, rev=0;
10+
cin>>n;
11+
while(n>0)
12+
{
13+
rev=rev*10+n%10;
14+
n=n/10;
15+
}
16+
cout<<rev<<endl;
17+
}
18+
return 0;
19+
}
20+

0 commit comments

Comments
 (0)