Homework 3: Due Thursday, September 14th

Complete the following problems on Chapter 2 material:

  1. For each of the following expressions, evaluate (solve) it. All numbers are integers.
         a.  3  +  6  *  2
         b.  (3  +  6)  /  2
         c.  2  +  4  /  2  +  5  *  4  -  2
         d.  (5  +  3)  /  4  %  2
         e.  3  +  4  /  22  *  3  +  3
         f.  25 /  4
         g.  25 % 4
  2. Determine which of the following is a valid identifier. If it is not valid, tell why.
         a.  income
         b.  21Century
         c.  const
         d.  Tom’s
         e.  two fold
         f.  income#1
         g.  account.doc
         h.  read_line
         i.  MyProgram
         j.  main
  3. Given the following mathematical formula, convert it to an equivalent and correct C++ expression.
         a.  b  -  4ac
    
         b.  x( y  +  z )
    
                         1
         c.       ----------------
                   x   +   x  *  3
    
                    a  +  b
         d.        ---------
                    c  -  d
  4. If a and b are int variables with a containing 5 and b containing 2, what output does each of the following statements produce?
         a.  cout  <<  "a =  "  <<  a  <<  "b =   "  <<  b  << endl;
         b.  cout  <<  "Result =  " <<  a   +  b  +  5  << endl;
         c.  cout  <<  "Result = " <<  a  *  b %  3  << endl;
         d.  cout  <<  "Result = " <<  b  /  a  +  3   << endl;
    

Read Chapter 3, from section 3.1 through section 3.3, and complete the following problems:


Remember to type your answers and to make two copies of each homework assignment. One copy is submitted to me and the other you keep to use in the group discussions.


Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2004