Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include "simpio.h"
- #include "math.h"
- #include "time.h"
- #define n 10000
- void initArray(bool primecap[]);
- void printTrue(bool primecap[]);
- int main()
- {
- int j, i, int1;
- printf("This program prints the first 10,000 primes.\n");
- bool primecap[n+1];
- initArray(primecap);
- int1=sqrt(n);
- primecap[0]=FALSE;
- primecap[1]=FALSE;
- for(i=2;i<=int1;i++)
- {
- for(j=2;j<=n/i;j++)
- {
- primecap[j*i]=FALSE;
- }
- }
- printTrue(primecap);
- getchar();
- }
- void initArray(bool primecap[])
- {
- int i;
- for(i=0;i<n;i++)
- {
- primecap[i]=TRUE;
- }
- }
- void printTrue(bool primecap[])
- {
- int i;
- for(i=0;i<n;i++)
- {
- if(primecap[i]==TRUE)
- {
- printf("%d\n", i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement