int prime(int number)
here is my code so far:
Expand|Select|Wrap|Line Numbers
- #include <stdio.h> //standard header file
- #include <conio.h> //header file
- #define maxp 250 //defines "maxp" as a value of 250 //
- int main() //start of main program
- {
- int factor; //declares "factor" as an integer
- int primefound; //declares "primefound" as an integer
- int i; //declares "i" as an integer
- int l; //declares "l" as an integer
- int number; //declares "number" as an integer (the number to be tested)
- int primearray[maxp];//declares an array of size determined by "maxp" (250)
- int c; //declares c as an integer (which is used has a counter)
- c=0; //initialises c = 0
- number=1; //initialises the number = 1
- while(c<maxp) // while is set up so that the loop executes whilst
- / c is lesss than 250(i.e. until 250 have been found)
- {
- number++; //increments the number under test
- primefound=1; //initialises primefound = 1
- for(i=2;i<number;i++) //this for loop increments i whilst checking to see if prime
- {
- factor = number%i; //by checking the remainder determines if prime or not
- if(factor ==0) //if no remainder ever occurs then the number is not prime, so:
- {primefound=0;} //set primefound to 0
- }
- if (primefound!=0) //if there is a prime number found then
- {
- primearray[c]=number; //put the number into the array in the order found.
- ++c; // increment c ready for the next prime number to be found
- }
- }
- for(l=0;l<maxp;l++) //this loop is used so that the whole array can be printed
- {
- printf("%d\n",primearray[l]);//prints the values in the array in order to the screen
- }
- getch();
- }
help please !
the second function is
void displayprime(int prime[])
which has to display the prime numbers in columns on the screen
can someone point me in the right direction ?