Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2. Consider the textbook figure 8.5 and the slice example in the lower left corner, matrix(:4, 2:8:2). Write the corresponding Go program (hw3.go file) to
2. Consider the textbook figure 8.5 and the slice example in the lower left corner, matrix(:4, 2:8:2). Write the corresponding Go program (hw3.go file) to create and use that slice. First create a 10x10 array and populate it with numbers from 1 to 100 in a row order. Then create the slice for that array Print the slice. Modify the array by adding 100 to all the elements in the second column. Print the slice again. The output must be: C[11 12 13 14] [31 32 33 34] [51 52 53 54] [71 72 73 74]] C[11 112 13 14] 31 132 33 34] [51 152 53 54] [71 172 73 74]] Make sure to comment your code and to explain how it works. (20 points) matrix(3:6, 4:7) matrix(6:, 5) matrix(:, (/2, 5, 9/)) Figure 8.5 Array slices (sections) in Fortran 90. Much like the values in the header of an enumeration-controlled loop (Section 6.5.1), a : b: c in a subscript indicates positions a, a c, omitted, 1 is assumed. It is even possible to use negative values of c in order to select positions in reverse order. The slashes in the second subscript of the lower right example delimit an explicit list of positions. 2. Consider the textbook figure 8.5 and the slice example in the lower left corner, matrix(:4, 2:8:2). Write the corresponding Go program (hw3.go file) to create and use that slice. First create a 10x10 array and populate it with numbers from 1 to 100 in a row order. Then create the slice for that array Print the slice. Modify the array by adding 100 to all the elements in the second column. Print the slice again. The output must be: C[11 12 13 14] [31 32 33 34] [51 52 53 54] [71 72 73 74]] C[11 112 13 14] 31 132 33 34] [51 152 53 54] [71 172 73 74]] Make sure to comment your code and to explain how it works. (20 points) matrix(3:6, 4:7) matrix(6:, 5) matrix(:, (/2, 5, 9/)) Figure 8.5 Array slices (sections) in Fortran 90. Much like the values in the header of an enumeration-controlled loop (Section 6.5.1), a : b: c in a subscript indicates positions a, a c, omitted, 1 is assumed. It is even possible to use negative values of c in order to select positions in reverse order. The slashes in the second subscript of the lower right example delimit an explicit list of positions
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