Problem Description
Rebecca was studying 2 nd standard.He wish to find the reverse of a given number using while loop.Help Rebecca in writing a C code.CODING ARENA
#include <stdio.h>
int main()
{
int n,rn=0,rem;
scanf("%d",&n);
while(n!=0)
{
rem=n%10;
rn=rn*10+rem;
n/=10;
}
printf("%d",rn);
return 0;
}
Test Case 1
Input (stdin)1234
Expected Output4321
Test Case 2
Input (stdin)5672
Expected Output2765
No comments:
Post a Comment