Question: ***in C*** Implement a function unsigned char *prime_vector(unsigned long num) that accepts a number num and returns a bit vector that indicates all the prime

***in C***

Implement a function unsigned char *prime_vector(unsigned long num) that accepts a number num and returns a bit vector that indicates all the prime numbers less than number num. You must allocate the appropriate amount of memory. For example, if num is 12, then the return character array must have 2 bytes with the following bit configuration:

***in C*** Implement a function unsigned char *prime_vector(unsigned long num) that accepts

Notice that all the bits in the last byte that correspond to num or above is set to 0 even though there may be a prime within (e.g., 13). Here is another example if num is 30.

a number num and returns a bit vector that indicates all the

You are encouraged to implement helper functions (e.g., is prime, set bit). Sample inputs and outputs:

prime numbers less than number num. You must allocate the appropriate amount

||| 2 | | ET | FT | SL | 0 | | || 6 | or | |1 0 |1 0 ||1|1|0|0|| 0 | 0 | 0 | 0 || 1 | 0 |0|0| OxAC Ox8 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 | 1010110000101000 OxAC 0x28 23 22 21 20 19 18 17 16 31 30 29 28 27 26 25 24 1000101000 100 000 0x8A Ox20 num Expected return bytes OxAC 0x28 0x8A 0x20 0x0 OxO Ox0 Ox4 Ox OxAC 0x8 OxAC Ox0 OxAC 0x28 0x8A OxAO 0x20 0x8A 0x20 0x28 0xAC 0x28 0x8A OxAO 0x20 0x8A 0x200x28 0x88 0x82 0x8 0x2 0xA2 0x28 0x2 0x0 124

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!