Question
7. Consider the following recursive function: void recFun(int u) { if (u == 0) cout < < Zero! ; else { cout < < Negative
7. Consider the following recursive function: void recFun(int u)
{ if (u == 0) cout << "Zero! ";
else
{ cout << "Negative "; recFun(u - 1);
}
}
What is the output of the function call as recFun(8). List all the steps as described with a ladder case for the example discussed in the Example -4 given before.
8. Consider the following function declarations - void getSeq(double x[], int sX); void showSeq(double x[], int sX); void showSumSquare(double x[], int sX); int getMax((double x[], sX);
The functions perform following task -
. getSeq performs the task of reading a sequence of numerical values taken as user input and stores them in into a double array. The array to store the data is the first parameter to the function and the number of and the number of values to be taken as input is the second parameter input.
. showSeq performs the printing a sequence of numerical values on the standard console which are stored in an array. The array storing the data is the first parameter to the function and the number of and the number of values in the array is the second parameter input.
. showSumSquare - performs the task of computing the summation of the square of the values stored in an array. The array having the stored data is the first parameter to the function and the number of and the number of values to be taken as input is the second parameter input.
. getMax - performs the task of finding the maximum value of from a sequence of numerical values which are stored in an array. The array storing the data is the first parameter to the function and the number of and the number of values in the array is the second parameter input.
Write a C++ program using the above functions so that the program performs following tasks in order.
1- Take the user input for the number of values to read from the user.
2- Invoke getSeq function to read the values from the user.
3- Invoke showSeq function to print values passed as the input.
4- Invoke showsumSquare to calculate and print the summation of square of the values taken as input.
5- Invoke getMax to calculate and print the maximum of the values taken as input.
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