hey seelplus now I get
Process returned 0 (0x0) execution time : 0.080 s
Press any key to continue.
nothing is wokring perty much !
I will explain everything
my task :
•Create a function called, nextFibo(int, int), which will contain two arguments, Fn-1and Fn-2. The function will generate the next Fibonacci number in the sequence based on the two previous Fibonacci numbers given as arguments
•The first two numbers in the sequence are: F0= 0 and F1= 1
•Hint: If you make the arguments in nextFibo() reference parameter variables, then you’ll shorten your program a bit.
•If the number 0 is typed in, an error message should appear.
•If the number 48 or greater is typed in, an error message should appear.
•The user should be able to display, correctly, the first 15 Fibonacci numbers in the Fibonacci series.
my code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
//This program is a Fibonacci sequence program
#include <iostream>
using namespace std;
void nextFibo(int , int ); //prototype function
int main()
{
void nextFibo(int , int ); // declaring
return 0;
}
void nextFibo() // this is the function
{
int num1, t1 = 0, t2 = 1, newT = 0;
cout << "How many num1bers in the Sequence do you want to display? ";
cin >> num1;
cout << "The sequence is : ";
for (int i = 1; i <= num1; ++i)
{
if(i == 1)
{
cout << endl << t1<<endl;
continue;
}
if(i == 2)
{
cout << t2 <<endl;
continue;
}
newT = t1+ t2;
t1 = t2;
t2 = newT;
cout << newT << endl;
}
}
|