Write appropriate notation for the first, third, and seventh elements of the following arrays:
a. int grades[20]
b. double volts[10]
c. double amps[16]
d. int dist[15]
e. double velocity[25]
f. double time[100]
Can someone please help me with this C++ array problem?
uh...
a) grades[0], grades[3], grades[6]
b) volts[0], volts[3], volts[6]
c) amps[0], amps[3], amps[6]
d) dist[0], dist[3], dist[6]
e) velocity[0], velocity[3], velocity[6]
f) time[0], time[3], time[6]
Since C++ arrays start at 0, the indices are off by one.
Reply:in arrays the index numbering starts from 0 rather than starting from one so to access the first element u write
(data type) a[length]
for the first element a[0]
for the third element a[2]
for the seventh element a[6] and so on
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment