Back To Java Loops Index
//program to input two numbers a and b and find sum of numbers between them using for statement public class forloopsumatob { public static void main(String[] args) { int a,b; int i; int sum=0; a=5; b=15; for(i=a;i<=b;i++) { sum=sum+i; } System.out.println("sum of numbers from a to b is " + sum); } }