problem no 6: Reverse the number.
QUESTION:
Given N, reverse the digits of N.
Example 1:
Input: 200
Output: 2
Explanation: By reversing the digts of number,
number will change into 2.
Example 2:
Input : 122 Output: 221 Explanation: By reversing the digits of number, number will change into 221.
ANSWER:
long long int reverse_digit(long long int n)
{
long long int result=0;
while(n>0)
{
int rem=n%10;
result=result*10+rem;
n=n/10;
}
return result;
}
Comments
Post a Comment