mkdir ~/cs255/c1 cp /home/cs255001/Handouts/c1/* ~/cs255/c1 


#ifndef EXTERN #define EXTERN extern #endif #define MAX 1000000 EXTERN unsigned int prime[MAX]; // Bit array EXTERN void sieveOfE( int N ); EXTERN int countPrimes( int N ); EXTERN void printPrimes( int k1, int k2, int N ); 
I have defined a bit array inside the header.h file that you must use in your primes.c C program.
The prime[ ] array is the bit array that represent whether a number k is prime (or not prime).
I have also included the function prototype (declaration) of the 3 functions that you need to write.
Each array element prime[i] is an unsigned int (= 32 bits): prime[0] is an unsigned int (= 32 bits) prime[1] is an unsigned int (= 32 bits) prime[2] is an unsigned int (= 32 bits) .... 
Please refer to this class note for more details: click here




Note: We have discussed bit array manipulation functions in class. Here is the webpage click here. You just need to adapt (may need to rewriting) them for this project.....


Therefore:

for ( i = 0; i < N; i++ ) { ClearBit(A, k); } 
to clear all the bits !!!
This is very inefficient.
You can clear all bits in an int typed variable using:
int x; x = 0; 
gcc g c main.c (once only !!!) gcc g c primes.c (every time you make changes in the file primes.c) gcc g o main main.o primes.o (every time you make changes) 
I strongly encourage you to write a Makefile for this project !
If you are successful, then all you need to do to compile the programs is typing: make....
main N For example: main 10000 
Sample outputs:
main 100 Number of primes found = 25 47 53 59 61 67 71 73 79 83 89 97 main 10000 Number of primes found = 1229 9883 9887 9901 9907 9923 9929 9931 9941 9949 9967 9973 main 31999999 Number of primes found = 1973815 31999823 31999829 31999837 31999853 31999883 31999901 31999907 31999909 31999921 31999927 31999939 


Procedure: see click here


/home/cs255001/turnin primes.c c1 
/home/cs255001/turnin header.h c1h 
/home/cs255001/turnin yourheaderfilename.h c1x 
/home/cs255001/reqext c1 
You request will be successful if you have not exceeded the maximum number of "free" (noquestionsasked) requests allowed