Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

Students also viewed these Databases questions