write a program to print the fibonacci serious up to 20th term
Answers
Answered by
0
#include<stdio.h>
int main()
{
int sum = 0, n=20;
int a = 0;
int b = 1;
printf("Fibonacci series: ");
while(sum <= n)
{
printf("%d ", sum);
a = b; // swap elements
b = sum;
sum = a + b; // next term is the sum of the last two terms
}
return 0;
}
Similar questions