why the while loop is not terminating? plz help me out in this..
import java.util.*;
import java.io.*;
class close1
{
public static void main(String[] args) throws IOException
{
int p,q;
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter values");
String s1=br.readLine();
p= Integer.parseInt(s1);
String s2=br.readLine();
q=Integer.parseInt(s2);
close c1=new close();
c1.find(p,q);
}
void find(int p,int q)
{
int ps;
int s[]=new int[18];
int lol,j,count=0,f=0,a;
boolean b;
for(lol=p;lol<=q;lol++)
{
j=0;
while(lol>0) /*why this loop is not terminating?*/
{
ps= lol%10;
j++;
lol = lol/10;
System.out.println(lol);
}
b= compare(s,j);
if(b==true)
count++;
}
int diff= q-p-count+1;
System.out.println(diff);
}
public boolean compare(int[] s,int j)
{System.out.print(s.length);
try
{
int y,z,count=1;
for(y=0;y<j-1;y++)
{
for(z=y+1;z<j-1;y++)
{
if(s[y]==s[z])
{count++;
if(count>3)
{return true;
}
}
}
}}
catch(Exception e)
{e.getCause();
}
return false;
}}
Re: why the while loop is not terminating? plz help me out in this..
Once is enough, twice is too many - your second post has been removed. Please read the link in my signature on getting help, it contains valuable information that might help you receive help faster
Re: why the while loop is not terminating? plz help me out in this..
This is my opinion on unterminating loops. They are simply infinite loops. Check your condition as you review your code and you will most likely find your problem hidden there. Fix it and move on.
Re: why the while loop is not terminating? plz help me out in this..
Quote:
Originally Posted by
elisha.java
This is my opinion on unterminating loops. They are simply infinite loops. Check your condition as you review your code and you will most likely find your problem hidden there. Fix it and move on.
What's the purpose of bumping old threads?
Last post on this thread was made on October 20, 2011 and you didn't even bother to read the thread's date. Neither you helped OP with any extra ordinary input that could help. Just saying few statements in many of your posts are not making you to help others. Try to view the latest topics that are being posted and try to help them. I hope you understand what i mean to say. I've been reading almost five to ten old threads bumped only by you. Watch it.