0
Please I donât understand the purpose of the second loop
I do have an array of objects(a counter type) And the increment the value of the array by 1 âI do want to print the sum of the array It gives 4950 as a results âI donât understand the purpose of the second loop for (j=0;j<I;j++) Why J is inferior than I I donât get it⊠https://code.sololearn.com/cCJA1ooJZNWL/?ref=app
2 Answers
+ 1
// I hope this will be of some help
int[] tab = new int[100];
Counter c = new Counter();
for(int i=0;i<100;i++){
c.up();
tab[i] = c.getValue();
sum= sum + tab[i];
}
0
I think there is error regarding to constructor.
1+(1+1) +(1+1+1) +(1+1+1+1) +.......
This is the output the program is going to produce .. Run from urself u may get idea by observing the output