Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Create a function called my_fibonacciSeries a. The function should generate a

ID: 3544316 • Letter: 1

Question

1.     Create a function called my_fibonacciSeries

a.     The function should generate a series of Fibonacci numbers.

b.     The range of number should start from the 0 and up to the total number entered by user. If user enters 50 then you should generate first 50 numbers.

c.      The function should also calculate the total of all Fibonacci numbers displayed.

d.     Function should be with one return value and one argument.

For example:  int my_fibonacciSeries(int )

(Fibonacci series: 0, 1, 1, 2, 3, 5, 8,

Explanation / Answer

#include<iostream>
using namespace std;
int my_fibonacciSeries(int count)
{
int a = 0;
cout << a << " ";
int b = 1;
cout << b << " ";
int sum = 1;
for(int i=2; i<=count; i++)
{
int c = a +b;
cout << c << " ";
sum = sum + c;
a = b;
b = c;
}
return sum;
}

int main()
{
int n;
cout <<"How many fibonacci numbers u need : ";
cin >> n;
cout << endl;
cout <<"first " << n << " fibonacci numbers are "<< endl;
cout << " Sum of " << n << " Fibonacci series is " << my_fibonacciSeries(n) << endl;
return 0;
}