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

Your assignment is to create a program that includes the following: • At least o

ID: 3769503 • Letter: Y

Question

Your assignment is to create a program that includes the following:

• At least one value returning function

• At least one void function

• At least one array (one-dimensional or two-dimensional)

• At least one loop structure (for, while or do-while) • At least one decision structure (if-else, switch)

• Use of the iomanip header file

***Please include a description of what your program is to accomplish upon submission. As long as your program includes the minimum specifications, compiles and runs without error, you are guaranteed a grade of at least 90% on this. Creativity and complexity will result in additional points.

Explanation / Answer

#include<string>

#include<iostream>

#include<iomanip>

using namespace std;

int* fibo(int n) {

int *arr = new int[n];

  

if (n==1) {

arr[0]=0;

} else if(n==2) {

arr[0]=0;

arr[1]=1;

} else {

arr[0]=0;

arr[1]=1;

  

for (int i=2; i<n; i++) {

arr[i] = arr[i-1] + arr[i-2];

}

}

  

return arr;

}

void display(int *arr, int n) {

cout<<" Fibonacci series till "<<n<<" is: ";

for (int i=0; i<n; i++) {

cout<<setw(3)<<arr[i];

}

}

int main() {

cout<<"-------Fibonacci series--------- ";

cout<<"Enter n: ";

int n;

cin>>n;

  

int *arr = fibo(n);

display(arr, n);

  

cout<<" ";

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote