# Leetcode Reverse Integer problem solution in C

Feb 10, 2023

In the Leetcode Reverse Integer problem solution in C programming Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 – 1], then return 0.

Assume the environment does not allow you to store 64-bit integers (signed or unsigned).

## Leetcode Reverse Integer problem solution in C programming

``````int reverse(int x){
long long int x1 = (long long int)x;
long long int rev  = 0;
long long int pop = 0;
long long int temp = 0;
if(x1<0)
{
x1=x1*(-1);
}
while(x1>0)
{
pop = x1%10;
x1 = x1/10;
temp = rev*10 + pop;
rev = temp;

}
if(x1<0)
{
return rev*-1;
}
else if(rev>=2147483647 || rev<=-2147483648)
{
return 0;
}
else if(x<0)
{
return rev*-1;
}
else
{
return (rev);
}
}``````

#### By Neha Singhal

Hi, my name is Neha singhal a software engineer and coder by profession. I like to solve coding problems that give me the power to write posts for this site.