Write a program in c to print fabonnaci series
Flowchart:
Algorithm:-
· start
· declare variable i,n,n1,n2,n3
· intialize n1=0,n2=1 and n3=0
· input number
· i=2
· check i<=n then n3=n1+n2,n1=n2,n2=n3
· display n3
· stop
Program:
#include<stdio.h> #include<conio.h> void main() { int i,n,n1=0,n2=1,n3; Clrscr() Printf(“Enter the number:”); Scanf(“%d”,&n); Printf(“The fibonnaci series :\n”); Printf(“%d \n”,n2); for(i=3;i<=n;i++) { n3=n1+n2; printf(“%d \n”,n3); n1=n2; n2=n3; } getch(); }
Output:-
Enter the number of terms: 10 Fibonacci Series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34,
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Flowchart:
Algorithm:-
· start
· declare variable i,n,n1,n2,n3
· intialize n1=0,n2=1 and n3=0
· input number
· i=2
· check i<=n then n3=n1+n2,n1=n2,n2=n3
· display n3
· stop
Program:
Output:-
need an explanation for this answer? contact us directly to get an explanation for this answer