Write
a program to print the first ‘n’ terms of Fibonacci series.
Today we are writing a program about Fibonacci series.
Fibonacci simply is a series of number in which third number is the sum of preceding
numbers.
Now let’s start the program.
#include<stdio.h>
void main ();
{
Int a=0, b=1, sum, n, counter=0;
clrscr ();
printf (“\n how many terms you want to calculate= “);
scanf (“%d”, &n);
printf (“%d \t”, a);
printf (“%d \t”, b);
while (counter < (n-2) )
{
sum = a+b ;
printf ( “ %d \t”, sum);
a=b;
b=sum;
counter = counter +1 ;
}
getch();
}
OUTPUT: -


Comments
Post a Comment