Question: My code for finding reverse by recursion says **Segmentation Fault**
Why?And how to find reverse by recursion?
What is wrong with my code?

```
 #include<stdio.h>
int rev(int);
main()
{
    int a,b;
    scanf("%d",&a);
    b=rev(a);
    printf("%d",b);
}
int rev(int x)
{
    int q,r;
    static int p=0;
    p=p*10+(x%10);
    r=x/10;
   q=rev(r);
    return(p);
}

```

Answer: 
You are using `q=rev(r);` without any conditions, i.e. you jump deeper and deeper into the recursive calls, and this never ends. 

In the end, you get a stack overflow.
Add any breaking condition in your code in you rev() function

```
if x == 0:
       return 0

```