Question
C++ #include using namespace std; void f( int[],int ); void fr (int[], int, int); double q( double[], int); double qr( double[], int, int); int main()
C++
#include
void f( int[],int ); void fr (int[], int, int); double q( double[], int); double qr( double[], int, int);
int main() { int myArray[5] = { 66, -100, 5, 0, -14 }; cout
cout
return 0; }
//prints contents of integer array void f( int ar[],int size ) { for (int i = 0; i
//recursive version of f void fr (int ar[], int current, int size) { if ( current
//calculates the sum of elements in double type array pr double q( double pr[], int size ) { double sum = 0; for ( int i = 0; i 0) sum = sum + pr[i]; return sum; }
//recursive version of q double qr( double pr[], int current, int size ) { if ( current 0 ) return pr[current] + qr(pr,current+1,size); else return qr(pr,current+1,size); } else return 0; }
O Welcone to Firefox X Students NSU M51 Labs-Spring 2018-Comp Pro 260Laboratory 10SP2018pdf https:/su m/bbcswebdav/pid-2173804-dt-content-rid-34049683 1/courses/CSC-260L-PARENT.01.03-172/260La In 3 -+ Automatic Zoom CSC 260L Laboratory 10 Spring 2018 Some Fun with Recursion Examine the code of recursive functions in Lab10.cpp and see below Write the following two functions in the Lab10.cpp file and run each on the array int arr[10]-400, 3, -66, 7,-6, 201, 199,-4, 0, 77 i (1) Write a recursive function that prints out the values of and integer element function from index size-1 to 0. EXAMPLE: if the array in the parameter to the function were int a[4]- (9, 5, 33, 2), the output would be 2 33 5 9 Name this function as firstnitialLastNamePrintRecursion (2) Write a value-returned recursive function to return the number of integer array elements that are either 99. (50 points each) Name this function as firstlnitialLastNamePrintOutOand99Recursion Write a test program (with main()) to test your two functions out. Be sure that your output is self-explained with nice descriptive sentences to show what will be printed out. For example, you can print out the original array first, then you can print out the list by using recursive algorithm, and last you can print out the numbers that are either 99
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started