9 Public Class Main 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 20 Public Static Void Main String 1 (41.94 KiB) Viewed 25 times
9 Public Class Main 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 20 Public Static Void Main String 2 (40.37 KiB) Viewed 25 times
9- public class Main { 10 11 12 13 14 15 16- 17 18 19 20 21 22 23 24 25 26 27 28 29 20 public static void main(String[] args) { // Initilizing value of sum and sumOfSquare variable to int sum = 0; int sumOfSquare = 0; // For loop in range 2 to 100 for (int i = 2; i <= 100; i++){ // Checking if i is even number or not if (i % 2. 0) { // If i is even than adding it into sum variable sum + i; I } } // Displaying result System.out.println("Sum of all even numbers in between 2 and 100 is // For loop in range 1 to 100 for (int j = 1; j < 100; j++){ // Adding square of j into sumOfSquare variable Sene Sum of all even numbers in between 2 and 100 is 2550 Sum of all squares between 1 and 100 is 338350 input + sum);
6789 16- 17 20 21 22 23 24 25 26 27 28 29 < 30 31 32 33 34 35 36 } } 77 TOT 10up in range 2 to 100 for (int i 2; i<100; i++){ // Checking if i is even number or not if (i % 2 == 0){ // If i is even than adding it into sum variable sum += i; } } // Displaying result System.out.println("Sum of all even numbers in between 2 and 100 is // For loop in range 1 to 10 for (int j = 1; j<= 100; j++){ // Adding square of j into sumOfSquare variable sumOfSquare + j*j; += } // Displaying result System.out.println("Sum of all squares between 1 and 100 is Sum of all even numbers in between 2 and 100 is 2550 Sum of all squares between 1 and 100 is 338350 input "1 + sum); + sumOfSquare);
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!