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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started