Write a program that determines the offset address for an


Question: Write a program that determines the offset address for an n-dimensional array (0 < n <= 4).  Assume an element size of 2.  The program should prompt the user to enter the following data:

row-major order or column-major order (R or C)

the number of dimensions for the array (a number)

the upper and lower bounds for each subscript

a set of subscripts

The program should output the total size of the array and the address offset for the selected subscript combination.  Allow the user to enter sets of subscripts until a -1 is entered. Terminate the program when a subscript of -1 is entered.  For example:

Enter (R)ow or (C)olumn major order (R or C): R

Enter the number of dimensions for the array: 3

Enter the upper and lower bounds for subscript 1: 1 4        

Enter the upper and lower bounds for subscript 2: 1 3

Enter the upper and lower bounds for subscript 3: 2 6

Enter a set of subscripts:        2 3 4

Offset to 2, 3, 4 is:     54

Array size is:  120

Enter a set of subscripts:        -1 -1 -1

Successful termination of program

Include comments in code section.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a program that determines the offset address for an
Reference No:- TGS0944988

Expected delivery within 24 Hours