ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2025 ICSE Computer Science Paper



Share with a Friend

Solved 2025 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Square root of sum of squares of all elements - NORM - ICSE 2025 Computer Science

Question 4

Define a class to accept values into a 4 × 4 integer array. Calculate and print the NORM of the array. NORM is the square root of sum of squares of all elements.

 

1

2

1

3

5

2

1

6

3

6

1

2

3

4

6

3

 

Sum of squares of elements = 1 + 4 + 1 + 9 + 25 + 4 + 1 + 36 + 9 + 36 + 1 + 4 + 9 + 16 + 36 + 9 = 201


NORM = Square root of 201 = 14.177446878757825

 

import java.util.Scanner; class Norm{ public static void main(String[] args){ Scanner in = new Scanner(System.in); int a[][] = new int[4][4]; int sum = 0; System.out.println("Enter array elements:"); for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ a[i][j] = Integer.parseInt(in.nextLine()); sum += a[i][j] * a[i][j]; } } double root = Math.sqrt(sum); System.out.println("NORM = " + root); } }

Output

 
OUTPUT 1:
Enter array elements:
4
2
6
1
8
4
1
2
3
5
6
7
8
9
10
11
NORM = 25.03996805109783

OUTPUT 2:
Enter array elements:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
NORM = 38.67815921162743