//IN CASE OF DOUBT, COMMENT IT
# include<stdio.h>
int fibo(int n);
int r;
void main()
{
int i, j, k, l = 0;
scanf("%d",&j);
for(i = 0; i < j; i++)
{
for( k = 0; k <= i; k++)
{
l = fibo(k);
printf("%d ", l);
}
printf("\n");
}
}
int fibo(int n)
{
if(n == 0)
{
return (0);
}
else if(n == 1)
{
return (1);
}
else
{
r = fibo(n- 1) + fibo(n-2);
return r;
}
}
Check the condition...it is given that if n=0 or n=1 then we have to took value 0.
ReplyDeletethe condition given to us is wrong. this condition will give the correct answer or the desired output. we were told to change the 0 to n
Delete