Test #1

Fri, NOV 3, 2000

Part I - one point each

From: C++ How to Program, by H. M. Deitel and P. J. Deitel

Teacher: Dr. B.J. Shrestha

Answer the following questions from your book:

1.10: Categorize each of the following items as either hardware or software:

  1. _______________ CPU

  2. _______________ C++ compiler

  3. _______________ ALU

  4. _______________ C++ preprocessor

  5. _______________ input unit

  6. _______________ an editor program


    1.12: Fill in the blanks in each of the following statements:

    1. Which logical unit of the computer receives information from outside the computer for use by the computer? _________________

    2. The process of instructing the computer to solve specific problems is called _________________.

    3. What type of computer language uses English-like abbreviations for machine language instructions? _________________

    4. Which logical unit of the computer sends information that has already been processed by the computer to various devices so that the information may be used outside the computer? _________________

    5. Which logical unit of the computer retains information? _________________

    6. Which logical unit of the computer performs calculations? _________________

    7. Which logical unit of the computer makes logical decisions? _________________

    8. The level of computer language most convenient to the programmer for writing programs quickly and easily is _________________.

    9. The only language that a computer can directly understand is called that computer's _________________.

    10. Which logical unit of the computer coordinates the activities of all the other logical units? _________________

    Part II - 2 points each

    Show all work in converting the number. Use the program in Part III to verify your answers.
    1. Convert the binary number 1110011 to decimal.

    2. Convert the decimal number 98 to binary.



    Part III - 10 points

    Compile and execute the following program. Turn in the program hardcopy (printout) stapled to the above questions (answered).

    //**************************************************
    //  Name:         John Doe/ Jane Doe
    //  Assignment:   #1
    //  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;
       }
       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);
    
    }