Announcements
We will have a simple 5 minute quiz at the beginning of the lab on Blackboard. Please sign in to your Blackboard account and finish the quiz individually. To access the quiz, go to CS 141 course on Blackboard, and click on Lab Quizzes, there you can find Lab 4 quiz. To access the quiz, you will need a password, which will be announced by the TA in the lab.
The full version of lab assignment is on Blackboard, under the link "Lab Assignments" > "Lab 7 Programming Activity". To access the assignment, you need a password, which will be announced by the TA in the lab.
You must work with a single partner, in a group of 2. You must take turns being the “driver” and the “navigator”. (If there are an odd-number of students in the class, your TA will make an adjustment.)
Lab Activity
During the lab, you will need to implement functions to practice the following base conversion problem:
1. Complete the function:
int convertBinaryArrayToDecimal( int digits[ 8]) { }
This function takes in an array of 8 binary digits as parameter and returns the decimal value of it.
2. Complete the function:
void convertDecimalToBinaryArray( int numberToConvert, int binaryDigits[ 8]) { }
This function takes in a single digit decimal number "numberToConvert" as one parameter and converts it to binary digits, which are stored in the
other parameter: the binaryDigits array.
3. (Extra Credit) Complete the function: char convert4BinaryBitsToHex( int binaryDigits[ 4]) { }
This function takes in an array of 4 binary digits and returns the hexadecimal character corresponding to the 4 Binary bits.
Sample running results:
Name: Jean Ma, Nilanjana Basu
netids: gma4, nbasu4
Lab section: 8 am Tues
==============Stage 1==============
Please enter 8 binary digits
0 0 0 1 0 0 0 1
The corresponding decimal is : 17
==============Stage 2==============
Please enter any single digit decimal number
2
The corresponding Binary is: 00000010
==============Stage 3==============
Please enter 4 binary digits: 1 0 1 0
The corresponding Hexadecimal is: A
End of Base conversion program
=========================
**Download the driver code below to start with.