1import java.util.Scanner;
2
3public class Main {
4
5 public static void main(String[] args) {
6
7 Scanner scanner = new Scanner(System.in);
8
9 System.out.print("Enter two numbers: ");
10 int num1 = scanner.nextInt() , num2 = scanner.nextInt();
11
12 int sum = num1 + num2 ;
13 System.out.printf("The sum of %d and %d is %d",num1, num2, sum);
14 }
15}
1public class SumNatural {
2
3 public static void main(String[] args) {
4
5 int num = 100, sum = 0;
6
7 for(int i = 1; i <= num; ++i)
8 {
9 // sum = sum + i;
10 sum += i;
11 }
12
13 System.out.println("Sum = " + sum);
14 }
15}