Design an algorithm, draw a corresponding flow chart and write a program in C, to print the Fibonacci series.10m Jun2006

By | June 14, 2014

Design an algorithm, draw a corresponding flow chart and write a program in C, to print the Fibonacci series.10m Jun2006

An algorithm is a finite set of steps defining the solution of a particular problem. An algorithm is expressed in pseudo code – something resembling C language or Pascal, but with some statements in English rather than within the programming language

  1. A sequential solution of any program that written in human language, called algorithm.
  2. Algorithm is first step of the solution process, after the analysis of problem, programmers write the algorithm of that problem.

Pseudo code: 

  • Initialize I to zero, Num1 to zero, Num2 to one
  • While I is less than 11
  •              Print Num1
  •              Initialize Num1 to Num2 & Num2 to Sum of Num1 & Num2
  •  Increment I
  • End

Detailed Algorithm:

Step 1:  I=0, Num1=0, Num2=1

Step 2:  While (I < 11)

                         Print Num1

                         Num1=Num2

                        Num2=Num1+Num2 

                       I++

Step 3:   End

 Flowchart:-

 FlowChart_Fibonacci

Code:

#include<stdio.h>
void main()
{
 int i,X=0,Y=1;
 clrscr();
 printf("\nFIBONACCI SERIES < 1000 ARE :- \n");
 i=0;
 while(i<11)
 {
     printf(" %d ",X);
     X=Y;
     Y=X+Y;
     i++;
 }
 getch();
}

Screen Shots:

C_program_Fibonacci_NonRec

C_program_Fibonacci_NonRec_Output

Solved Recursive program can be found on this link http://cssimplified.com/c-programming/a-c-program-to-find-the-fibonacci-series-of-numbers-using-recursion

Leave a Reply