Question: PRINT THE FOLLOWING CODE: Write C++ statements to: 1) Declare two arrays named myArraya and yourArray with capacity to store up to 100 whole numbers.

PRINT THE FOLLOWING CODE:

Write C++ statements to: 1) Declare two arrays named myArraya and yourArray with capacity to store up to 100 whole numbers. 2) Fill myArray according to the following rules: A) the first element of the array gets a value equal to the current index B) the rest of the elements get the value of the previous element plus a value equal to the current index 3) Fill yourArray with the values from myArray in reverse order. Declare any additional variables you need. Example: 0 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 190 171 153 136 120 105 91 78 66 55 45 36 28 21 15 10 6 3 1 0 ?

The code to fill in the values is the following:

1) Declare two arrays named myArraya and yourArray with capacity to store up to 100 whole numbers

int myArray[100], yourArray[100];

2) Fill myArray according to the following rules: A) the first element of the array gets a value equal to the current index B) the rest of the elements get the value of the previous element plus a value equal to the current index

for(int i=0;i<100;i++) { if(i==0){ myArray[i]=i; } else { myArray[i]=myArray[i]+myArray[i-1]; } }

3) Fill yourArray with the values from myArray in reverse order. Declare any additional variables you need.

for(int i=99;i>=0;i--) { yourArray[i] = myArray[i]; } However, I wanted to know how to print the elements in order to check that the array is correct. MUST BE IN C ++ LANGUAGE, thanks!!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!