Lab7

Announcements

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