I'm new to Arrays and Functions

0 LaV Brown · August 1, 2015
What do you do if you want to use certain array positions for calculations or for printing. For example, if an array has 4 places and you want to use the data in position 4 to either use in a formula for calculations or printing just that position, how would you code it at that point in the function?

Post a Reply


Oldest  Newest  Rating
0 Dol Lod · August 2, 2015
I don't get the question.

To access data in the fourth position in the array going from 0 ... length-1, you use brackets.

I.e. element 4 would be array[3] where array was declared.
0 Jon Z. · August 2, 2015
I'm not sure what you are trying to ask, but to access the 4th element in an array
array[3] = value;
//for 1st element array[0]
//for 2nd element array[1]
0 Sha Kal · August 2, 2015
Trying to figure out haha. Tho i don't know what you are trying to do but i am sure there is much easier way to it. If you wanna share piece of code or something here, i'd like to help you if i can, i mean, i am still learning as well but i have got much farther than arrays.
0 Scott Walker · August 14, 2015
int myArray[5] = {1, 2, 3, 4, 5}; //first element is always 0, therefore '1' is in array space '0'
int sum = 0;

sum = sum + myArray[3];

//sum is equal to whatever sum was plus whatever is in array space 3, in this case, the number 4. Therefore sum = 4

Get that?
  • 1



Used in many types of software including music players, video games, and many large scale applications.

Bucky Roberts Administrator