But it doesn't work perfectly, it will only return true if x is equal to index 99 of W.
Follow what I wrote and you'll get what you want.
Type: Posts; User: newbie
But it doesn't work perfectly, it will only return true if x is equal to index 99 of W.
Follow what I wrote and you'll get what you want.
Oh i see.
Well that loop currently does pretty much nothing.
You need to place the if and else statements inside the while loop.
What's giving you the error is, you're incrementing i from 0 to...
I'm going to assume you haven't changed much in you're while loop and say the following:
An array of size 100, has indices ranging from 0 99 inclusive.
Because you're incrementing i, (i++;)...
Yeah, that would be what you're after.
Also consider replacing the while loop with a for loop, it's more convenient than storing a counter variable yourself.
Of course it will function exactly the...
if(i<w.length) //if found
return true;
Think about that for a minute, what you're essentially saying is...
If 1(and upwards) is less than 1000, return true.
How does 1 being less than...