Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a brief answer to the following questions. 1. Assume the following declara

ID: 3785738 • Letter: W

Question

Write a brief answer to the following questions.

1. Assume the following declarations are made and indicate which items below are valid sub- scripted variables.

A. a[0]

B. b[0]

C. c[1.0]

D. b['a']

E. b[a]

F. a[x + y]

G. a[x % y]

H. a[10]

I. c[-1]

J. a[a[4]]

2. Assume that the array a defined in Question 1 contains the following values.

1 4 6 8 9 3 7 10 2 9
Indicate if the following are valid subscripts of a and, if so, state the value of the subscript.

If invalid, explain why.

A. a[2]

B. a[5]

C. a[a[2]]

D. a[4 + 7]

E. a[a[5] + a[2]]

F. a[Math.sqrt(2)]

Explanation / Answer

1. The valid statements are a[0],b[0],a[x+y],a[x%y].
a[a[4]] cannot be said as valid unless we know the value of a[4].

2. The valid statements are a[2],a[5],a[a[2]].

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote