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)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education