Sunday, August 2, 2009

Help with this problem involving Arrays in Computer Programming?

double[] decList = {9.0,8,7.5,10.5,3,4};


double total=0;


for(int spot=0; spot%26lt;decList.length; spot++){


total=total+decList[spot];


}


out.println(total);





What would the output of this Array be?

Help with this problem involving Arrays in Computer Programming?
You suck cock :)
Reply:If you can't figure it out, just run it and see what happens. Then see if you can figure it out from there.
Reply:it would be the total of all those numbers in the array added together.


9+8+7.5+10.5 + 3 +4 = 42.0
Reply:42
Reply:All this is doing is adding together the elements of the array. It's kinda ammusing, but the answer is 42.


No comments:

Post a Comment