logo CodeStepByStep logo


Author: Cynthia Lee (on 2016/11/03)

Create a bit vector set from the given array of values (arguments are an array of int and its size, as int [] and int). Returns an unsigned short that represents a bit vector set of the values from the array. The bits in positions 1-9 of the returned result mark the set membership, the remaining bits are zeros.

Precondition: every number in the values array is the range 1-9. Assume the array size is correct. Implementation can assume client is responsible for meeting precondition.

For example, if the input is {5, 3, 7}, then make_set returns 168 (binary 0000000010101000 -- note bit positions 5, 3, and 7 are 1).

Type your C solution code here:

This is a function problem. Write a C function as described. Do not write a complete program; just the function(s) above.

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.

© Marty Stepp, all rights reserved.