import java.util.Scanner;
public class ArrayMaximum {
public static void main(String args[])
{
System.out.println("Enter the limit for array :");
Scanner in=new Scanner(System.in);
int limit=in.nextInt();
int array[]=new int[limit];
System.out.println("enter the values for array :");
for(int i=0;i<array.length;i++)
{
array[i]=in.nextInt();
}
System.out.println("Values of array");
for(int m:array)
{
System.out.print(" "+m);
}
System.out.println();
int max=array[0];
for(int j=1;j<array.length;j++){
if((array[j])>max)
max=array[j];
else
max=array[0];
}
System.out.println("biggest Number in this array "+ max);
}
}
No comments:
Post a Comment
Please post your comments. Your comments make us to write more programs for you.