Last active
December 26, 2015 08:29
-
-
Save imryan/7122504 to your computer and use it in GitHub Desktop.
Counts to 100, adding each number inclusively.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Count { | |
public static void main(String[] args) | |
{ | |
// Declare variables | |
int i = 0; | |
int index = 0; | |
while (i != 100) | |
{ | |
// Iterate i and add index to i, adding 1 each iteration | |
i++; | |
index += i; | |
} | |
// Output the final value | |
System.out.println("1 - 100 added inclusively: " + index); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment