Wednesday, 5 September 2012

c program for fibonacci series using array and for loop

For beginners
{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(software) for windows 7  like Code::Blocks,dev c++ Download dev c++ its free and install it in your computer.open  dev c++ go to file-->new-->source file.}


#include<conio.h>
#include<stdio.h>

int main (void)
{
int Fibonacci[1000], i,m;
printf("enter no of element in fidonacci series(only<1000)\n");
scanf("%d",&m);
printf("-------------------\n");
Fibonacci[0] = 0;
Fibonacci[1] = 1; 
for ( i = 2; i < m; ++i )
Fibonacci[i] = Fibonacci[i-2] + Fibonacci[i-1];
for ( i = 0; i < m; ++i )
printf ("%i\n", Fibonacci[i]);
getch();
return 0;
}

Output


enter no of element in fidonacci series(only<1000)
10
-----------------------------
0
1
1
2
3
5
8
13
21
34


For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}

IS IT HELPFIL? comment.

No comments:

Post a Comment