CS3843 – Solved

$ 20.99


Implement the following bit manipulation methods using C language.

void displayBits(unsigned int n); unsigned int setKthBit(unsigned int n, int k); int isPowerOfTwo(unsigned int n); int getNoBits(unsigned int a, unsigned int b); unsigned int computeXor(unsigned int n);

Descriptions of these functions are as follows:

• dsplayBits: Displays an unsigned integer in bits. Print a space after every 8 bits. •
• setKthBit: Sets the kth bit of n from the right to 1.
• isPowerOfTwo: returns 1 of n is a power of 2 and 0 otherwise.
• getNoBits: returns the number of bits required to convert a to b.
• computeXor: computes the XOR of all the numbers from 1 to n (including n).

The following files are available for you to use with this assignment:

Descriptions of these files are as follows:
• Lab1main.c: This is the main file that calls the methods and includes the test cases
• Lab1.out: This is the output when methods are implemented and called from Lab1main.c

Add your methods to FirstLastLab1methods.c and compile it with assign1main.c as follows to produce the executable.
gcc Lab1main.c FirstLastLab1methods.c -o Lab1

Redirect the output of executable and use Linux command diff to compare the output file with the one provided with the Lab1.out. Modify if needed and submit your FirstLastLab1methods.c to BB.


There are no reviews yet.

Be the first to review “CS3843 – Solved”

Your email address will not be published. Required fields are marked *