Reverse The Number ||codechef||beginner solution ||programming info

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

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

Share:

No comments:

Post a Comment

Translate

Recommended platforms

  1. codechef
  2. hackerrank
  3. codeforces
  4. leetcode
  5. hackerearth

Popular Posts

programming_info. Powered by Blogger.

Blog Archive

Recent Posts

other platforms

  • geeks for geeks
  • w3schools
  • codepen
  • skillshare
  • udemy

Pages

reader support Support