Java - Sum integers between two values using for loop

Description

Sum integers between two values using for loop

Demo

import java.util.Scanner;

class Range {//from  w  w  w  . j  ava2  s  . c  o  m

  public static void main(String[] args) {
    int a, b, sum = 0;
    Scanner sc = new Scanner(System.in);
    System.out.println("Enter first positive Two digit number");
    a = sc.nextInt();
    System.out.println("Enter second positive Two digit number");
    b = sc.nextInt();

    for (int i = a; i <= b; i++) {
      sum = sum = i;

    }
  }
}

Related Exercise