As you recall, numbers can be represented in various bases. A base describes how many unique digits are used is representing the number. For example, we mostly represent numbers in base 10; there are 10 different digits used to represent the numbers: 0,1,2,3,4,5,6,7,8,9. Numbers can be represented in many (infinite!) other bases, such as base 8. In base 8 the numbers are represented with only 8 digits: 0,1,2,3,4,5,6,7.
The actual value of a number depends on both what digits are used, and the location of the digits. Obviously, the number 123 is smaller than the number 321. In particular the farther left a digit is, the more contribution it makes to the size of the number. If we number the columns from right to left, starting with 0, then when the base is b and the digit d is in column c, the the contribution of that digit to the value of the number is d*bc. For example the number 123 base 10 (written 12310) is 3*100 + 2*101 + 1*102, which totals 123. For a less obvious example, 1238 is 3*80 + 2*81 + 1*82, which totals 83.
The reason you're reading all this is because computers don't store their numbers in base 10, but rather in base 2 (the only digits are 0 and 1). As computer programmers, we need to be able to convert numbers from the binary (base 2) format to the decimal (base 10) format. That is what you will do for the lab.
What to do
You will write a program that converts a number from binary to decimal format. You will then print out the decimal value of that number.
Just as one might want to convert from binary to decimal, one might want to perform the conversion the other direction (decimal to binary). The basic principle is the same, except instead of multiplying by powers of two, we need to divide (and mod) by the powers of two. For example, if the decimal number is 11 and we want to convert to a 4 bit binary number, then the leftmost bit (column 3) is 11/(23), or 1.
What to do
You will write a program that converts a number from decimal to binary format. You will then print out the binary value of that number. You need to figure out how to perform the conversion. You know the first step.
There is a different way of converting from a decimal number to a binary one, but starting with the rightmost bit, rather than the left. It involves division by the base (not raised to any power) repeatedly.
What to do
Determine how to generate a binary number from a decimal number, starting with the rightmost bit. Repeat part 2 using this technique.