to find prime numbers
I know the concept to find prime numbers but its giving error please help me out this is code i have coded for the following question but its not correct.
class Prime
{
public static void main(String[] args)
{
int[] num={12,34,35,42,9,76,31,54,99,150};
int i,j,c=0;
for(i=0;i<10;i )
{
for(j=1;j<=num[i];j )
{
if(num[i]%j==0)
{
c=c 1;
}
}
if(c==2)
System.out.println("prime number is :" num[i]);
else
System.out.println("no prime number");
}
}
}
please teach me correct code and help me out by giving the solution to the following programme.
1. Consider an array with ten elements 12,34,35,42,9,76,31,54,99,150. Please write a program to find the prime number in the array and to print the number and it's index position in the array.
Hint: Use the example program as reference.