View Single Post
Old Oct 27th, 2005, 6:13 PM   #4
2roll4life7
Programmer
 
2roll4life7's Avatar
 
Join Date: Aug 2005
Location: 0x0010 * 0x0091 + 0x0004
Posts: 65
Rep Power: 4 2roll4life7 is on a distinguished road
All you did was present us with your (likely homework) problem. You didn't tell us how you've already tried to solve the problem or provide us with any code you've started with (besides the function skeletons [that it looks like your teacher gave to you]). You havn't been specific enough either. Like what should the program do if there are no primes at all in the array? Throw an exception, bail, prompt the user, look in another array?
private boolean isPrime(int num) {
	int i = 2;
	while(i < num) {
		int j = num % i;
		if(j == 0)
			return false;
		else
			i++;
	}
	return true;
}
I'm providing you with one of the functions I've written that you'll obviously need. I left it uncommmented on purpose. If you can't figure out the rest of what you need to make those functions work, I suggest you take a different class.
__________________
#if 0 /* in case someone actually tries to compile this */
- libpng version 1.2.8 (example.c)

<Jim_McNeat> Is there like a way to put a compiler in "Just trust me on that one" mode?
2roll4life7 is offline   Reply With Quote