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

This needs to be in c ++ if you can help me out please. im confused. Write a pro

ID: 3715980 • Letter: T

Question

This needs to be in c ++ if you can help me out please. im confused.

Write a program that creates two integer arrays of size ten. Use a        constant for array size.

a). Initialize the first array with values 10,20,30,40,50,60,70,80,90         and 100 in main() function.

b). Create a void function reverseNums() that uses a loop to copy all of the      values of the first array in reverse to the second array. reverse_nums()      function is called by Main () function.

c). Create a void outputArray()function to display all the elements in array      in increment order. Output both first and second arrays.  

Explanation / Answer

#include <iostream>

using namespace std;
void reverseNums(int a[], int rev[], int size) {
for(int i=0,j=size-1;i<size;i++,j--) {
rev[i] = a[j];
}
}
void outputArray(int rev[], int size) {
for(int i=0;i<size;i++) {
cout<<rev[i]<<" ";
}
cout<<endl;
}
int main()
{
const int size = 10;
int a[size] = {10,20,30,40,50,60,70,80,90,100};
int rev[size];
cout<<"Array elements: "<<endl;
outputArray(a, size);
reverseNums(a,rev,size);
cout<<"Array elements in reverse order: "<<endl;
outputArray(rev, size);
return 0;
}

Output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote