Lab7
Announcements
We will have a simple 10 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 Quiz, there you can find quiz 7. To access the quiz, you will 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 binary to decimal conversion problem:
1. (1 point) Covert the following binary numbers to decimal numbers by hand.
i. 01101
ii.10101
iii. 00110
2. Complete the function (binary to decimal conversion):
The program should prompt for the 0/1 values to be stored into an array of 5 int locations. This array represents a binary array.
int convertBinaryArrayToDecimal( int digits[ 5]) { }
This function takes in an array of 5 binary digits as parameter, print the array within the function and returns the decimal value of it.
(1 point) print the array within the function
(extra point) covert binary array to decimal value.
Sample running results:
Name: Jean Ma
netids: gma4
============================
Please enter 5 binary digits
0 0 0 1 0
The binary array : 0 0 0 1 0
The corresponding decimal is : 2
2-21-2017