Question: Write a Fortran program that declares two integer arrays of length 4. a. Set the values in the first array to [-2, 0, 2, 4]

Write a Fortran program that declares two integer arrays of length 4.

a. Set the values in the first array to [-2, 0, 2, 4] by initializing on the line where the array is declared. Print the array using fields 3 characters wide for each element.

b. Set the values in the first array to [-2, 0, 2, 4] by using a counting loop whose loop index variable goes from 1 to 4 and finding a formula that converts the loop variable into the needed values. (Spend some time thinking about this, as it may be useful later.) Print the array using fields 5 characters wide for each element.

c. Prompt the user for any 4 integer values (they needn't be the ones from parts a and b) and read them into the first array directly. Do not declare extra variables to do this. Print the array. d. Use a loop to fill a second array with the values from the first array in reverse order. Print the second array.

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!