Tuesday, 23 August 2016

Fibonacci Series Using Array And For Loop - C Programming Examples

Fibonacci Series Using Array
As we have started C Programming coding with Example Series, We have published last posts
"Write A Program For SUM of Infinite HP"

"Write A Program To Find SUM of AP" and

"Write A Program To Find SUM of GP Sequence".

We have chosen to start with Arithmetic Series and in this post you will find some basic idea and some useful concepts about Fibonacci Numbers .You can download C Codes below.Please let us know your feedback.

In this post we are doing again Fibonacci Series but with different approach.In last post "Fibonacci Progression Using While Loop" you will see how to generate Fibonacci Numbers by using concepts of  Do-While Loop.In this post we will talk about another loop i.e. For Loop and side by side Concept of Arrays will be discussed and demonstrated.

Fibonacci Series - Sequence ( Using Array And For Loop ) Video Tutorial(See C- Codes Below ):

For Loop Concept: FOR Loops are the most useful type. The syntax for a for loop is 
for ( variable initialisation; condition; variable update ) {
  Code to execute while the condition is true

A working Example of FOR Loop

#include <stdio.h>

int main()
    int x;
    /* The loop goes while x < 10, and x increases by one every loop*/
    for ( x = 0; x < 10; x++ )
        /* Keep in mind that the loop condition checks 
           the conditional statement before it loops again.*/   
        printf( "%d\n", x );

Array Concept: Arrays may be defined as a kind of data structure that can store a fixed-size sequential collection of elements of the same type.An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.

Arrays are of two types:
A. One-dimensional arrays
B. Multidimensional arrays

Readers' Choice