C program compilation error

when this code is compiled to calculate the return value of f(p,p), if the value of p is initialized to 5 before the call? Note that
the first parameter is passed by reference, whereas the second parameter is passed by
value
#include<stdio.h>
int f(int *p ,int f);
int main()
{
int p=5,y;
y=f(&p,p);
printf("%d",y);
return 0;
}
int f(int &x,int c)
{
c = c - 1;
if (c==0)
return 1;
else
x = x + 1;
return f(x,c) * x;
}

but i am getting an error
what is wrong with my code??

Your function prototype and function definition are different. In prototype you have used pointer while you have used aliasing in definition. Use aliasing in prototype also.

1 Like