Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the code in C++ . Read very carefully DO NOT ASSIGN anything directly to a

ID: 3791246 • Letter: W

Question

Write the code in C++.
Read very carefully DO NOT ASSIGN anything directly to array b

Paste your code as the answer to this problem. With a screenshot of it working.

Problem: Create a program that will print out the integer values in arrays al20 and b120] You will dynamically allocate these arrays as needed. Initialize the array a with some random value, and increment by one for each element in the array. The values of the elements in array a must not overlap with the values of the elements in array b lf array a has the number 19, array b CANNOT have number 19, Example: aloj 19, a[1] 20, a[2] -21... etc b[0] 37, b[1] 38 etc

Explanation / Answer

// C++ code

#include <iostream>
#include <fstream>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
int SIZE = 20;

void setArray (int array1[], int number)
{
for (int i = 0; i < SIZE; ++i)
{
array1[i] = number;
number++;
}
}

void printARray(int array1[], int array2[])
{
cout << "Array a: ";
for (int i = 0; i < SIZE; ++i)
{
printf("%d ",array1[i]);
}

cout << " Array b: ";
for (int i = 0; i < SIZE; ++i)
{
printf("%d ",array2[i]);
}

cout << endl;
}

int main()
{
int i, *ptra, *ptrb;

ptra = (int*) malloc(SIZE * sizeof(int));
ptrb = (int*) malloc(SIZE * sizeof(int));

setArray(ptra, 40);

for (int i = 0; i < SIZE; ++i)
{
ptrb[i] = ptra[i] + 10;
}

setArray(ptra,10);

printARray(ptra,ptrb);

free(ptra);
free(ptrb);

return 0;
}

/*
output:

Array a: 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
Array b: 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

*/