Can we get fibonacci series without using for loop in main function as given

#include<stdio.h>

int fib(int n)

{

int i;

if(n==1)

return(0);

if(n==2)

return(1);

else

return(fib(n-1)+fib(n-2));

}

void main()

{

int n;

printf("no of terms");

scanf("%d",&n);

for(int i=1;i<=n;i++)

 printf("%d ",fib(n));

}

C Program to print Fibonacci Series without using loop - GFG

1 Like