The following example demonstrates the use of the do...while structure to find the sum of integer numbers from 0 to 100:
/* author by w3cschool.cc Main.java */public class Main { public static void main(String[] args) { int limit=100; int sum=0; int i=1; do { sum=sum+i; i++; } while(i<=limit); System.out.println("sum="+sum); }}
The output result of the above code is:
sum=5050
The above is the Java example - digital sum operation. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!