how to write a program for this ?

consider the following sequence of numbers :

1,1,2,3,5,8,13,21,34...

given the first two numbers of the sequence , say (f1 and f2 ),N^th number fn,n>=3 of this sequence is given by : fn=fn-1+fn-2

thus f3 = f2+f1=1+1=2 , f4=a3+a2=2+1=3 , and so on.

the number determined this way is called Fibonacci number . Suppose f2=7 and f1=3

then f3=f2+f1=7+3=10 ; f4=f3+f2=10+7=15.

using this information , write a program that determine and output desired number of the Fibonacci sequence given first two numbers . (f1 and f2) of the sequence and desired number (n) of the Fibonacci sequence is interactively entered into the program by the user . your program should continue to allow user to find the N^th Fibonacci number given first two numbers if the response is positive . please make use of more than one function ( example get_input , cal_fib_sequence,display_result) to solve this problem .
you haven't even googled it...
Trying to cheat on your homework, eh?

I won't give you the code, but you might want to use an array and make a for loop up to the desired number. Good luck!
i think u can do this:

int number1;
int number2;
int number3;
etc etc till your numbers

then a random function

then:

if (randomfunction > 100)
{

number1 = x;
number2 = x + 1;
number3 = x + 2;
etc etc
}

hope i helped
@vitinho lolwut? How about an array instead of all those variables? And what's with the "random function" ? What is it; what does it do? And as for the end, do you even know what a Fibonacci sequence is? Try http://en.wikipedia.org/wiki/Fibonacci_sequence .
Last edited on
Topic archived. No new replies allowed.