Quote:
infact when i am using char in place of int it is showing error.
Because of your compiler oddities.
A C compiler should not even compile your code.
#include<stdio.h>
int main()
{
int n,i;
printf("enter n\n");
scanf("%d",&n);
fun(n);
}
int fun(int x)
{int i;
char c='*';
if(x>=1)
{for(i=1;i<=x;i++)
printf("%c",fun(x-1));
}
else
return c;
}
Quote:
why it is not showing error as return value is not of type int.
Because of compiler internals, it can handle some things and not some others.
No one can predict what will be ok or not without empirical experiment.