javascript
Brief description  about Online courses   join in Online courses
View nishant  gaurav 's Profile

program error

class branch
{
public static void main(String[] args)
{
int[] a={12,34,35,42,9,76,31,54,99,150};
int i;
boolean gotit=false;
for(i=0;i<a.length;i )
{
for(int j=2;j<a[i];j ){
if(a[i]%j!=0)
{
gotit=true;
break;
}
}

}
if(gotit)
{
System.out.println("found the prime no is" a[i] "at index" i);
}
else
{
System.out.println("no number is prime in given array");
}
}
}
Asked by nishant gaurav | May 5, 2010 |  Reply now
Replies (1)
View arun kumar das 's Profile
Hi

check this code, you did some syntax error, take care.


class branch
{
public static void main(String[] args)
{
int[] a={12,34,35,42,9,76,31,54,99,150};
int i;
boolean gotit=false;
for(i=0;i<a.length;i++)
{
for(int j=2;j<a[i];j++)
{
if(a[i]%j!=0)
{
gotit=true;
break;
}
}
}

if(gotit)
{
System.out.println("found the prime in given array");
}
else
{
System.out.println("no number is prime in given array");
}
}
}



java teacher
Dec 24, 2010