import java.util.*;
class nw
{
int dis(int p)
{
int c=0,flag=0;
for(int j=1;j<=p;j++)
{
if(p%j==0)
c++;
}
if(c==2)
return 1;
}
void hui()
{ int c;
int p,q;
Scanner sc=new Scanner(System.in);
System.out.println("range p");
p=sc.nextInt();
System.out.println("range q");
q=sc.nextInt();
for(int i=p;i<=q;i++)
{
c=dis(i);
if(c==1)
{
System.out.println(i);
}}}}
{it says missing return statement! can anyone tell me whats exactly wrong in this program}

well, one problem is: you post this twice within four minutes.

missing return statement is most likely caused by this:

if(c==2)
return 1;

there is no return set in case c != 2, and the compiler is looking for a return statement for each and every scenario.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.