Reverse string

Description:

If an Integer N, write a program to reverse the given number. Input The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer N. Output Display the reverse of the given number N. Constraints 1 <= T<= 1000 1 <= N <= 100000 Test Case 1 Input (stdin) 3 12345 31203 2123 Expected Output 54321 30213 3212 Test Case 2 Input (stdin) 2 78657 100034 Expected Output 75687 430001

Program :

#include <stdio.h>


int main(void) {

int t;

scanf("%d",&t);

while(t--)

{

    int n,rev=0,rem;

    scanf("%d",&n);

    while(n!=0)

    {

        rem=n%10;

        rev=rev*10+rem;

        n=n/10;

    }

    printf("%d\n",rev);

}

return 0;

}