hi! i am really sorry but i don't have any idea on how i will create code that generates N series of Fibonacci numbers using array

# n series of fibonacci using array

Page 1 of 1## 7 Replies - 16715 Views - Last Post: 15 October 2008 - 04:36 AM

##
**Replies To:** n series of fibonacci using array

### #2

## Re: n series of fibonacci using array

Posted 14 October 2008 - 05:38 AM

Create an array of length N and then fill each index between 0 and N with the number accordingly to the fib sequence.

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this:

Thanks.

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this:

Thanks.

### #3

## Re: n series of fibonacci using array

Posted 14 October 2008 - 05:41 AM

Generally, there are some rules:

[rules][/rules]

But I've got nothing better to do, so...:

[rules][/rules]

But I've got nothing better to do, so...:

#include <iostream> using namespace std; // born2c0de's recursive fibonacci method long fib(unsigned long n) { if (n <= 1) { return n; } else { return fib(n-1)+fib(n-2); } } int main() { cout << "How big do you want the sequence to be?\t"; int input; cin >> input; int fibonacci[input]; for (int i = 0; i < input; i++) { fibonacci[i] = fib(i); } for (int i = 0; i < input; i++) { cout << fibonacci[i] << " "; } cin.get(); return EXIT_SUCCESS; }

### #4

## Re: n series of fibonacci using array

Posted 14 October 2008 - 05:43 AM

There are snippets available on this topic. Go to the snippets section and see if you can get them.

### #5

## Re: n series of fibonacci using array

Posted 14 October 2008 - 06:06 AM

You can also use Google

### #6

## Re: n series of fibonacci using array

Posted 14 October 2008 - 08:03 AM

hi again,,..

after brain freeze,,

i hope that you'll help me to correct all my errors.

#include<stdio.h>

#define MAX 50

main()

{

int i;

int fib[i];

clrscr();

printf("ENTER TWO NUMBERS:\n\n");

scanf("%d\n %d\n", &fib[0], &fib[1]);

for(i=2;i< MAX-1; i++);

{

fib[i]= fib(i-1)+ fib(i-2);

printf("%d", &fib[i]);

}

getch();

}

after brain freeze,,

i hope that you'll help me to correct all my errors.

#include<stdio.h>

#define MAX 50

main()

{

int i;

int fib[i];

clrscr();

printf("ENTER TWO NUMBERS:\n\n");

scanf("%d\n %d\n", &fib[0], &fib[1]);

for(i=2;i< MAX-1; i++);

{

fib[i]= fib(i-1)+ fib(i-2);

printf("%d", &fib[i]);

}

getch();

}

### #7

## Re: n series of fibonacci using array

Posted 14 October 2008 - 08:05 AM

hi again,,..

after brain freeze,,

i hope that you'll help me to correct all my errors.

after brain freeze,,

i hope that you'll help me to correct all my errors.

#include<stdio.h> #define MAX 50 main() { int i; int fib[i]; clrscr(); printf("ENTER TWO NUMBERS:\n\n"); scanf("%d\n %d\n", &fib[0], &fib[1]); for(i=2;i< MAX-1; i++); { fib[i]= fib(i-1)+ fib(i-2); printf("%d", &fib[i]); } getch(); }

### #8

## Re: n series of fibonacci using array

Posted 15 October 2008 - 04:36 AM

You might be expecting something like this...

As I wrote this code on the fly, it might have some errors. Just have a close look on it.

I hope this will help you.

cout << "How many numbers in series? : "; cin >> count; cout << fibo1 << " " << fibo2; for(i=2;i<count;i++) { tmp = fibo1; fibo1 = fibo2; fibo2 += tmp; cout << " " << fibo2; }

As I wrote this code on the fly, it might have some errors. Just have a close look on it.

I hope this will help you.

Page 1 of 1