Create a function int Fibonacci(int n), that will calculate the Fibonacci number.
Use the parameters in main, int argc, char *argv[].
1
Expert's answer
2012-12-25T10:10:51-0500
#include <iostream> #include <conio.h>
using namespace std;
int Fibonacci(int n) { int curr = 1; int prev = 1; int tmp;
for (int c = 3; c <= n; c++) { tmp = curr; curr += prev; prev = tmp; } return curr; }
void main(int argc, char* argv[]) { if (argc != 2) return; int n = atoi(argv[1]); cout << "Fibonacci number for N = " << n << " is " << Fibonacci(n) << endl; getch(); }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment