Lab 8
Announcements
We will have a simple 5 minutes’ quiz at the beginning of the lab on Blackboard. Please sign in to your Blackboard account and finish the quiz individually. Most of your time should be focussed on finishing the lab activity questions.
You must work with a single partner, in a group of 2. You must take turns being the “designated driver” and the “non-driver”. (If there are an odd number of students in the class, your TA will make an adjustment.)
LAB 8 - Base conversion
In today's lab we will practise base conversion from Binary to Decimal and Decimal to Binary.
Tasks
Download the starter code Lab8Question.cpp and start working on that by following
the instructions below.
Stage 0 - 1 point
--------
Complete the function convert4DigitBinaryToDec. This function takes in a 4 digit
binary number as a parameter and returns the decimal value of it. Code to read in
the binary number and print the decimal output has already been set up for you.
You will only have to write code for the base conversion
Stage 1 - 1 point
--------
Complete the function convertDigitToBin. This function takes in a single digit
decimal number as a parameter and returns the binary value of it. Once again, code
for reading in the decimal number and printing out the binary output has been written
for you. You only have to write code for the conversion.
Stage 2 - 1point
---------
Complete the function convertIntToBin. This function takes in an integer between
32 and 64 as a paramter and returns the binary value of it.
Note : Feel free to change the data type of the parameters and return type of any of
the functions as you wish.