Back To Java Loops Index
//program to find sum of even numbers from 1 to 10 using for statement public class forloopsumeven1to10 { public static void main(String[] args) { int i; int sumeven=0; for(i=1;i<=10;i++) { if(i%2==0) { sumeven=sumeven+i; } } System.out.println("sum of even numbers from 1 to 10 is " + sumeven); } }