/* Slip no : 9_1 write a prog to
calculate sum of fibonacci series up to given no */
#include<stdio.h>
#include<conio.h>
int main()
{
int
n,first=0,second=1,sum;
printf("Enter the
range of the Fibonacci series: ");
scanf("%d",&n);
printf("Fibonacci
Series: ");
printf("\n %d\t
%d\t ",0,1);
while(n>0)
{
sum = first + second;
first = second;
second = sum;
printf("%d\t ",sum);
n=(n-1);
}
getch();
}
No comments:
Post a Comment