Q:

My code returning 0 Actually it should return reverse of input

I wrote the following C code for school and I can't seem to find out why it returns 0. I have to use recursive number of digits and power functions to recursevely reverse the input number(the reverse function has to be a 1 parameter function):
#include<stdio.h>

int digits(int x)
{
    if(x!=0)
        return 1 + digits(x/10);
    else
        return 0;
}

int power(int x,int y)
{
    if(y!=1)
        return x*power(x,y-1);
    else
        return x;
}

int reverse(int x)
{
    static int nr=0;
    if(digits(x)!=1)
        return nr + power(10,digits(x)-1)*(reverse(x/10)%10);
    else
        return x;

}

int main()
{
    int x;
    scanf("%d",&x);
    printf("%d\n",reverse(x));
    return 0;
}

A:

you almost had it right, the only thing wrong was how you connected the recursive output.
just change :
return nr + power(10,digits(x)-1)*(reverse(x/10)%10);

to :
return power(10,digits(x)-1)*(x%10) + (reverse(x/10));

