Program to implement fibonacci series:-
code:
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c,i,n;
a=0;
b=1;
printf("\n Enter the value of n which will terminate the series after reaching nth value:");
scanf("%d",&n);
printf("\n Fibonacci series generated \n");
printf("\t%d\t%d",a,b);
for(i=0;i<n;i++)
{
c=a+b;
a=b;
b=c;
printf("\t%d",c);
}
getch();
}
output:-
code:
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c,i,n;
a=0;
b=1;
printf("\n Enter the value of n which will terminate the series after reaching nth value:");
scanf("%d",&n);
printf("\n Fibonacci series generated \n");
printf("\t%d\t%d",a,b);
for(i=0;i<n;i++)
{
c=a+b;
a=b;
b=c;
printf("\t%d",c);
}
getch();
}
output:-
No comments:
Post a Comment