ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2007 ICSE Computer Science Paper



Share with a Friend

Solved 2007 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Maximum & Minimum Program - ICSE 2007 Computer Science

Write a program to initialize the given data in an array and find the minimum and maximum values along with the sum of the given elements.
Numbers: 2, 5, 4, 1, 3
Output:
Minimum value: 1
Maximum value: 5
Sum of the elements: 15

class List{ public static void main(String args[]){ int a[] = {2, 5, 4, 1, 3}; int min = a[0]; int max = a[0]; int sum = a[0]; for(int i = 1; i < a.length; i++){ if(max < a[i]) max = a[i]; if(min > a[i]) min = a[i]; sum += a[i]; } System.out.println("Minimum element: " + min); System.out.println("Maximum element: " + max); System.out.println("Sum of the elements: " + sum); } }

Output

 
 OUTPUT : 
Minimum element: 1
Maximum element: 5
Sum of the elements: 15