- #1
- 7
- 0
I'm given a source file:
int main()
{
bool running = true;
string pre_sum;
int fib_th;
while (running)
{
cout << "Which Fibonacci number would you like me to compute ? ('q' to quit) ";
cin >> pre_sum;
fib_th = atoi(pre_sum.c_str());
if ( pre_sum[0] == 'q' )
{
running = false;
}
else if ( fib_th >= 0 )
{
if ( fib_th % 10 == 1 )
cout << "The " << fib_th << "st Fibonacci number is " << fibb(fib_th) << endl;
else if ( fib_th % 10 == 2 )
cout << "The " << fib_th << "nd Fibonacci number is " << fibb(fib_th) << endl;
else if ( fib_th % 10 == 3 )
cout << "The " << fib_th << "rd Fibonacci number is " << fibb(fib_th) << endl;
else
cout << "The " << fib_th << "th Fibonacci number is " << fibb(fib_th) << endl;
}
}
cout << "Goodbye." << endl;
return 0;
}
I have to define the funtion:
int fibb(int num_in);
in a new file to have the program compute whatever fibonacci number is requester by the user.
any suggestions?
Thanks.
int main()
{
bool running = true;
string pre_sum;
int fib_th;
while (running)
{
cout << "Which Fibonacci number would you like me to compute ? ('q' to quit) ";
cin >> pre_sum;
fib_th = atoi(pre_sum.c_str());
if ( pre_sum[0] == 'q' )
{
running = false;
}
else if ( fib_th >= 0 )
{
if ( fib_th % 10 == 1 )
cout << "The " << fib_th << "st Fibonacci number is " << fibb(fib_th) << endl;
else if ( fib_th % 10 == 2 )
cout << "The " << fib_th << "nd Fibonacci number is " << fibb(fib_th) << endl;
else if ( fib_th % 10 == 3 )
cout << "The " << fib_th << "rd Fibonacci number is " << fibb(fib_th) << endl;
else
cout << "The " << fib_th << "th Fibonacci number is " << fibb(fib_th) << endl;
}
}
cout << "Goodbye." << endl;
return 0;
}
I have to define the funtion:
int fibb(int num_in);
in a new file to have the program compute whatever fibonacci number is requester by the user.
any suggestions?
Thanks.