1.

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

Answer»

class maxmin 

public static void main() 

int [ ]n = {2,5,4,1,3}; 

int h=n[0]; 

int l=n[0];

int s=0; 

for(int i=0; i<n.lenght; i++)

{

if (h<n[i])

{

h=n[i] 

if (i<n[i])

{

l=n[i]; 

s=s+n[i]; 

System.out.println(“Minimum Value :”+l); 

System.out.println(“Maximum Value :”+h); 

System.out.println(“The Sum of the elements :”+s); 

}



Discussion

No Comment Found

Related InterviewSolutions