Q:

Write a program in c to print fabonnaci series

0

Write a program in c to print fabonnaci series

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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, 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Programming Exercises With Solutions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a Function to check uppercase letter... >>
<< Write a program in c to find even or odd numbers...