Teacher: Dr. B.J. Shrestha
Answer the following questions from your book:
1.11: Fill in the blanks in each of the following statements:
//************************************************** // Name: John Doe/ Jane Doe // Professor: Dr. B. J. Shrestha //************************************************** // This program converts a Base 10 number into // its equivalent Base 2 number. //************************************************** #include <iostream.h> int main() // Storage for conversion int base10, bdigits[16]; int tmpbase10, numdigits, i; // Input Base 10 number cout << "Enter base 10 number < 32000: " cin >> base10; // Convert to Base 2 tmpbase10 = base10; for ( i = 0; i < 16 && tmpbase10 != 0; i++ ) { bdigits[i] = tmpbase10 % 2; tmpbase10 /= 2.0; } numdigits = i; // Display conversion cout << base10 << " Base 10 is "; for ( i = numdigits - 1; i >= 0; i-- ) { cout << bdigits[i]; } cout << " Base 2\n"; return(0);