Ask your own question, for FREE!
Computer Science 9 Online
OpenStudy (anonymous):

0

OpenStudy (anonymous):

You only want to add one value to sum each loop and you haven't use done to end loop. I see 2 options if you follow the instructions that i has to be incremented before use. I didn't test them but think I didn't miss anything. Option 1 void setup() { done=0; //to make sure it is false sum=0; i=0; } void loop() { i++; sum=sum+data[i-1]; if (i==10) done=1; } Option 2 void setup() { done=0; //to make sure it is false sum=0; i=-1; //start i at -1 to avoid subtraction in indexing } void loop() { i++; sum=sum+data[i]; //index changed to just i if (i==9) done=1; //check changed to 9 }

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Arriyanalol: i need help
1 day ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
1 day ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!