import java.util.*;
class Arr
{
int arr[]=new int[20];
int i,j,n,c,max;
Scanner sc=new Scanner(System.in);
public void show()
{
for(i=0;i<20;i++)
{
System.out.print("\nValue:");
arr[i]=sc.nextInt();
}
max=0;
System.out.print("\nValues=");
for(i=0;i<20;i++)
System.out.print(" "+arr[i]);
for(i=0;i<20;i++)
{
n=arr[i];
c=0;
for(j=1;j<=n;j++)
{
if(n%j==0)
c++;
}
if(c==2 && n>max)
max=n;
}
if(max==0)
System.out.print("\nList has no Prime Number");
else
System.out.print("\nMax Prime "+max);
}
}
class Arr
{
int arr[]=new int[20];
int i,j,n,c,max;
Scanner sc=new Scanner(System.in);
public void show()
{
for(i=0;i<20;i++)
{
System.out.print("\nValue:");
arr[i]=sc.nextInt();
}
max=0;
System.out.print("\nValues=");
for(i=0;i<20;i++)
System.out.print(" "+arr[i]);
for(i=0;i<20;i++)
{
n=arr[i];
c=0;
for(j=1;j<=n;j++)
{
if(n%j==0)
c++;
}
if(c==2 && n>max)
max=n;
}
if(max==0)
System.out.print("\nList has no Prime Number");
else
System.out.print("\nMax Prime "+max);
}
}
No comments:
Post a Comment