Code:
import java.io.*;
import java.lang.*;
import java.util.Scanner;
class arra
{
public static void main(String args[])throws IOException
{
int sum=0,avg,max,mini,n,i;
Scanner in=new Scanner(System.in);
System.out.println("enter three number");
n=in.nextInt();
int[] h= new int[n];
System.out.println("enter the value");
for(i=0;i<n;i++)
{
h[i]=in.nextInt();
}
for(i=0;i<n;i++)
{
sum=sum+h[i];
}
System.out.println("sum of the array"+sum);
avg=sum/n;
System.out.println("sum of the average"+avg);
max=h[0];
mini=h[0];
for(i=0;i<n;i++)
{
if(h[i]>max)
{
max=h[i];
}
else if(h[i]<mini)
{
mini=h[i];
}
}
System.out.println("maximum value"+max);
System.out.println("minimum value"+mini);
}
}
No comments:
Post a Comment