0
1.7kviews
Write a C program to generate the first n terms of the Fibonacci sequence using while loop
1 Answer
0
212views

Code:-

#include<stdio.h>

#include<conio.h>

 void main()

{

int f0,f1,f,n,i; 

printf("Enter the no of values in Fibonacci Sequence "); 

scanf("%d",&n);

f0=0;

f1=1;

printf("FIBONACCI SEQUENCE FOR THE FIRST %d TERMS:\n",n); 

i=0;

while(i<n)

{

printf("%d\t",f0); 

f=f0+f1;

f0=f1; 

f1=f; 

i=i+1;

}

}

Output:-

enter image description here

Please log in to add an answer.