The below program (that I didn't write) prints to the screen the first 100 prime numbers. I am tiring to get it to put the 100 prime numbers into an array.
Code:
#include <stdio.h>
int main(int argc, char *argv[]) {
int p, number;
int count=0;
p=2;
while (count < 100) {
number=2;
while (number < p) {
if (p % number == 0) {
number = p;
}
number=number+1;
}
if (number == p) {
printf("%03d. prime number is %4d\n", count+1, p);
count=count+1;
}
p=p+1;
}
return 0;
}
I started by defining an array "int prime [100];" and the printf function above and replaced it with "p=prime[]" then "p=prime[100]" , then "p=prime" and finally "prime=p", but it wouldn't work