IN THIS POST I HAVE SHOWN HOW TO FILL UP AN ARRAY WITH FIRST 10 ,20, 30 OR ANY NUMBER AND ALSO OF ANY TYPE OF NUMBERS
BELOW I HAVE SOLVED A SIMILAR PROGRAMING OF FILL UP OF AN ARRAY OF FIRST 10 COMPOSITE NUMBER
LOGIC WILL BE SAME FOR ALL THE TYPE OF NUMBERS TAKEN
EG-
import java.util.*;
class fill_complete
{
void main()
{
int a[]=new int[10],i,m,c,k,f=0;
for(i=1;;i++)
{
m=i;
c=0;
for(k=1;k<=m;k++)
{
if(m%k==0)
{
c++;
}
}
if(c>2)
a[f++]=i;
if(f==10)
break;
}
System.out.println("The first 10 composite no in the array are as follows");
for(i=0;i<f;i++)
{
System.out.println((a[i]));
}
}
}
USE THIS SAME LOGIC WITH ANY TYPE OF NUMBERS