Implementation of 0~100 and Java

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

    The classical problem, three variables respectively represents the starting end, and from the beginning to the end, for cycle, and continue to accumulate. The following code:


public class ForLoop {
    public static void main(String[] args){
        int limit=100;
        int sum=0;
        for(int i=1;i<=limit;i++)
        {
            sum=sum+i;
        }
        System.out.println("sum="+sum);
    }
}

    Results figure


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Michelle at November 15, 2013 - 1:21 PM