2.1) The program in Figure 2 performs certain task. Compile the program and answer the following questions: a) What is the value of d? b) What is the value of d if num[] is stored with {33,44,55,77,66,55,44,99,22,11}? c) (2 marks) (2 marks) What is the value of d if num[] is stored with the numeral digits of your student number? (for example BK20123456, will be stored as 2,0,1,2,3,4,5,6) d) Based on the values of d, what does the Mystery function do? (2 marks) (2 marks)

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.3: Interactive While Loops
Problem 6E: (Conversion) a. Write a C++ program to convert meters to feet. The program should request the...
icon
Related questions
Question
2.1) The program in Figure 2 performs certain task. Compile the program and answer the following
questions:
a)
2.2)
b)
d)
What is the value of d?
What is the value of d if num[] is stored with {33,44,55,77,66,55,44,99,22,11}?
(2 marks)
c) What is the value of d if num[] is stored with the numeral digits of your student number?
(for example BK20123456, will be stored as 2,0,1,2,3,4,5,6)
Based on the values of d, what does the Mystery function do?
#include <iostream>
using namespace std;
(2 marks)
Write another program that can perform the same task. The program should be different from the
one given in Figure 2. *Copy and paste your program AND output.
int Mystery(int array[], int a, int b);
int main()
{
int a1,a2,d;
int num[] = {17,0,-61,12,200,10,69,-55,77,123,-29};
a1 = 0; a2 = sizeof(num)/sizeof(num[0])-1;
d = Mystery (num,a1,a2);
cout << "The value of d is " << d;
return 0;
}
int Mystery(int array[], int a, int b)
{
}
int c;
if(a ==
else
{
b)
return array[a];
c = Mystery(array,a+1,b);
if(array[a] >= c)
return array[a];
else
(2 marks)
return c;
Figure 2
(2 marks)
(6 marks)
Transcribed Image Text:2.1) The program in Figure 2 performs certain task. Compile the program and answer the following questions: a) 2.2) b) d) What is the value of d? What is the value of d if num[] is stored with {33,44,55,77,66,55,44,99,22,11}? (2 marks) c) What is the value of d if num[] is stored with the numeral digits of your student number? (for example BK20123456, will be stored as 2,0,1,2,3,4,5,6) Based on the values of d, what does the Mystery function do? #include <iostream> using namespace std; (2 marks) Write another program that can perform the same task. The program should be different from the one given in Figure 2. *Copy and paste your program AND output. int Mystery(int array[], int a, int b); int main() { int a1,a2,d; int num[] = {17,0,-61,12,200,10,69,-55,77,123,-29}; a1 = 0; a2 = sizeof(num)/sizeof(num[0])-1; d = Mystery (num,a1,a2); cout << "The value of d is " << d; return 0; } int Mystery(int array[], int a, int b) { } int c; if(a == else { b) return array[a]; c = Mystery(array,a+1,b); if(array[a] >= c) return array[a]; else (2 marks) return c; Figure 2 (2 marks) (6 marks)
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning