i show u the code that i have edit.it about the same as yours..u try and run it..
Code:
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
int main()
{
int arrayofprimes[100];// create space for array
int top,remainder,numberofprimes,value,prime,i;
int minusONE;//pointer for array
//Has to be moved out of the two nested loops for finding primes.
printf("pls enter top limit:");
scanf("%d",&top);
prime = 1;
numberofprimes = 0;
do
{
for(minusONE = (top / 2); minusONE > 1; minusONE--) //Top / 2 is not the best, sqrt top is, but it's way better than top - 1
{
remainder = top % minusONE;
printf("\n%d / %d remainder is %d", top, minusONE, remainder);
if(remainder==0) //it's not a prime number, so stop processing it.
{
prime = 0;
break; //break out of the for loop.
}
} //end of for
// if prime == 1 at this point, you have a prime number. Add this if statement, and put the prime number, into the array.
if(remainder==1)
{
arrayofprimes[numberofprimes++] = top;
}
}while(--top > 3);
//print up the arrray of primes
for(i = 0; i < numberofprimes; i++)//why did u declare i ? what is the function of i ?
{
printf("array[%02d]",arrayofprimes[i]);
}
system("pause");
return 0;
}
i'm really a C program idiot.