Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

2. What are your challenges in the creative process?

Answered: 1 week ago