Reverse The Number
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
Example
Input 4 12345 31203 2123 2300 Output 54321 30213 3212 32
SOLUTION USING C LANGUAGE:-#include <stdio.h> int main(void) { int T,N,i,s,d; scanf("%d",&T); for(i=0;i<T;i++) { scanf("%d\n",&N); d=0; while(N>0) { s=N%10; d=d*10+s; N=N/10; } printf("%d\n",d); } // your code goes here return 0; }
No comments:
Post a Comment