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

***C++ program*** Assume that you have two arrays, A and B. Each has 10 cells. C

ID: 675043 • Letter: #

Question

***C++ program***

Assume that you have two arrays, A and B. Each has 10 cells. Complete these tasks in your program.

- Write a function and a loop inside to fill A with the numbers given by user. Function signature is "void FillA(int A[], int size)".
- Write a function and a loop inside to fill B with random numbers with 0-100. Function signature is "void FillB(int B[], int size)"
- Write a function to copy A to B. The function signature should be "void ACopy(int A[], int B[], int size)". This function copies content of A into B.
- Write a function to reverse A and keep the reversed ordered numbers in B. The function signature is "void ARev(int A[], int B[], int size)"
- Write a function to find the max of A (let it be MaxA) and fill B with MaxA. The function signature is "void AFillMax(int A[], int B[], int size)"

Call above function from the main() in order and print the content of the array A and/or B respectively.

Explanation / Answer

#include<iostream>

#include<time.h>

using namespace std;

void FillA(int A[], int size) {

for (int i = 0; i<size; i++) {

cout<<"Enter integer "<<(i+1)<<" :";

cin>>A[i];

}

}

void FillB(int B[], int size) {

for (int i = 0; i<size; i++) {

B[i] = rand() % 101;

}

}

void ACopy(int A[], int B[], int size) {

for (int i = 0; i<size; i++) {

B[i] = A[i];

}

}

void ARev(int A[], int B[], int size) {

for (int i = 0; i<size; i++) {

B[i] = A[size-i-1];

}

}

void AFillMax(int A[], int B[], int size) {

int max=A[0];

for (int i = 1; i<size; i++) {

if(A[i] > max)

max = A[i];

}

  

for (int i = 0; i<size; i++) {

B[i] = max;

}

}

int main() {

srand(time(NULL));

  

int size = 6;

int A[6], B[6];

  

FillA(A, size);

FillB(B, size);

  

cout<<" ";

return 0;

}