![Write a C Program to Generate Fibonacci Series Fibonacci Series, C program, Sumit kar, Timus Rak, 0 1 1 2 3 5 8 13 21](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgEEuiVQujzDYGlv1PMDzDKYb5ozvCbIjo_Mt3FOu_A8h6GVex9UkCglRQEuc0wTKxbm_OgzCSMsAl0xTsTrdYwnZVmL3fFis99MAlE7B7SZTE3u-l8-Yoy14a7zhjLCMXS_y2grkLeaBz/s1600/c-programming-tutorial.jpg)
0 1 1 2 3 5 8 13 21 ...
/* Using while loop */
#include<stdio.h>
void main()
{
int n,i,a,b,c;
printf("Enter th number of terms: ");
scanf("%d",&n);
i=1;
a=0;
b=1;
while(i<=n)
{
printf("%d ",a);
c = a + b;
a = b;
b = c;
i++;
}
}
/* Using for loop */
#include<stdio.h>
void main()
{
int n,i,a,b,c;
printf("Enter th number of terms: ");
scanf("%d",&n);
a=0;
b=1;
for(i=1;i<=n;i++)
{
printf("%d ",a);
c = a + b;
a = b;
b = c;
}
}
0 Comments