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

  •  T  1000
  •  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

x
+
cmd
4
12345
31203
2123 2300

Output

x
+
cmd
54321
30213
3212
32
Advertisements

Demonstration


CodeChef solution FLOW007  - Reverse The Number Codechef solution in C,C++

Previous
CodeChef solution TODOLIST - Problems in your to-do list Codechef solution in C,C++
Next
CodeChef solution NEGPROD - Negative Product Codechef solution in C,C++