An algorithm to print Fibonacci Series upto N term using while loop.

1) START

2) Initialize F1=0,F2=1,Term=3

3) Enter the term you want to generate Fibonacci series as N

4) Print value of F1 as first term and second term as F2

5) Check is Term <= N if TRUE then continue ELSE Goto Step 11

6) Fab = F1+F2

7) Print value of Fab

8) Assign F1=F2 and F2=Fab

9) Increment value of Term= Term+1

10) GOTO Step 5

11) END

Flowchart to print Fibonacci Series upto N term using while loop.

Flowchart  to print Fibonacci Series upto N term using while loop.
Flowchart to print Fibonacci Series upto N term using while loop.

C Program to print Fibonacci Series using upto N term while loop.

#include<stdio.h>
void main()
{
int gno,f1=0,f2=1,term=3,fab; //intialization of loop counter
printf("enter the term upto you want to print fabinacci series :");
scanf("%d",&gno);
printf("\n%d",f1);
printf("\n%d",f2);
while(term<=gno)//loop condition
            {
            fab=f1+f2;
            printf("\n %d",fab);
            f1=f2;
            f2=fab;
            term++;
            }
}

An algorithm to print Fibonacci Series upto N term using do…while loop.

1) START

2) Initialize F1=0,F2=1,Term=3

3) Enter the term you want to generate Fibonacci series as N

4) Print value of F1 as first term and second term as F2

5) Fab = F1+F2

6) Print value of Fab

7) Assign F1=F2 and F2=Fab

8) Increment value of Term= Term+1

9) Check is Term <= N if TRUE then GOTO Step 5

10) END

Flowchart to print Fibonacci Series upto N term using while loop.

Flowchart to print Fibonacci Series upto N term using do---while loop.
Flowchart to print Fibonacci Series upto N term using do—while loop.

Write a C Program to print Fibonacci Series using do….. while loop.

#include<stdio.h>
#include<conio.h>
void main()
{
int gno,f1=0,f2=1,term=3,fab; //intialization of loop counter
clrscr();
printf("enter the term upto you want to print fabinacci series :");
scanf("%d",&gno);
printf("\n%d",f1);
printf("\n%d",f2);
do{
            fab=f1+f2;
            printf("\n%d",fab);
            f1=f2;
            f2=fab;
            term++;
            }while(term<=gno);//loop condition
            getch();
   }

C-Code to print Fibonacci Series using for loop.

#include<stdio.h>
#include<conio.h>
void main()
{
int gno,f1=0,f2=1,term,fab; //intialization of loop counter
clrscr();
printf("enter the term upto you want to print fabinacci series :");
scanf("%d",&gno);
printf("\n%d",f1);
printf("\n%d",f2);
for(term=3;term<=gno;term++)
  {        
    fab=f1+f2;
    printf("\n%d",fab);
    f1=f2;
    f2=fab;
  }
getch();
}