0

Why not make int i=0 while initializing? I dont get that logic.

https://code.sololearn.com/c7Z1AYNpU426/?ref=app

11th Apr 2020, 11:58 AM
Shankar Devaraju
Shankar Devaraju - avatar
2 odpowiedzi
+ 3
Hi Shankar Devaraju iterations need not necessarily begin with a value 0 and this code calculates sum of first 100 natural numbers so you need not include 0. You generally start iteration from value 0 when you are traversing an array or a String or any other collection because Java has zero based indexing.
11th Apr 2020, 1:04 PM
Avinesh
Avinesh - avatar
+ 2
Natural Numbers donot include 0
11th Apr 2020, 12:06 PM
Abhiraj Ghumare
Abhiraj Ghumare - avatar