Algorithm
problem Link : https://www.codechef.com/problems/FLOW007
Problem
Given an Integer N, write a program to reverse it.
Input
The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer N.
Output
For each test case, display the reverse of the given number N, in a new line.
Constraints
- 1 ≤ T ≤ 1000
- 1 ≤ N ≤ 1000000
Sample 1:
Input
Output
4 12345 31203 2123 2300
54321 30213 3212 32
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include<stdio.h>
int main()
{
int n,num,r;
scanf("%d",&n);
while(n--)
{
scanf("%d",&num);
int revNum=0;
while(num!=0)
{
r=num%10;
revNum=revNum*10+r;
num=num/10;
}
printf("%d\n",revNum);
}
}
Copy The Code &
Try With Live Editor
Input
4
12345
31203
2123
2300
12345
31203
2123
Output
54321
30213
3212
32
30213
3212
32
Demonstration
CodeChef solution FLOW007 - Reverse The Number Codechef solution in C,C++