Lab 09

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Laboratory 09: Object-Oriented Programming (OOP) (Valid grade for the second cut).

The submission deadline for the assignment is Tuesday, October 24th, at 23:59 hours, via
the virtual platform. The submission should not be delayed beyond this deadline. The
assignment allows a maximum of two students to collaborate. Please note that groups
consisting of three students will not be permitted under any circumstances. Only one of the
two students should upload the report to Moodle.

The report for the assignment is expected to be written in English. Additionally, you are
required to present the assignment in class on Wednesday, October 25th.

Your adherence to these deadlines and presentation requirements is appreciated.

Write a C++ function named apply_all that expects two arrays of integers and their sizes and
dynamically allocates a new array of integers whose size is the product of the 2 array sizes

The function should loop through the second array and multiplies each element across each element
of array 1 and store the
product in the newly created array.

The function should return a pointer to the newly allocated array.

You can also write a print function that expects a pointer to an array of integers and its size and
display the elements in the array.
Both arrays must be provided by cin.
For example,

Below is the output from the following code which would be in main:

array1[] {1,2,3,4,5}; // it should be provided by cin


array2[] {10,20,30};// it should be provided by cin

cout << "Array 1: " ;


print(array1,5);

cout << "Array 2: " ;


print(array2,3);

int *results = apply_all(array1, 5, array2, 3);


cout << "Result: " ;
print(results,15);

Output
---------------------
Array 1: [ 1 2 3 4 5 ]
Array 2: [ 10 20 30 ]
Result: [ 10 20 30 40 50 20 40 60 80 100 30 60 90 120 150 ]
The code must be able to be copied and pasted
To accomplish this, kindly adhere to the sequential stages of the programming
methodology:
• Problem Analysis.
• Problem Specification.
• Algorithm Design.
• Algorithm Testing and Refinement.
• Code Implementation.
• Testing and Verification.

You might also like