Problems 04

  1. Homework H4.1: Evaluate: 2/10+6
  2. Homework H4.2: Evaluate: 5-20%6
  3. Homework H4.3: Evaluate: 2.0/10+6
  4. Homework H4.4: Given:
    int a[] = {9, 9, 9, 9};
    int i = 1;
    a[i] = i++;
    
    When the code above executes there are two possible sets of results for a[1] and a[2]. What are they?
    set 1:                            set 2:
    
    a[1] =                            a[1] =
    a[2] =                            a[2] =
    
  5. Homework H4.5: Convert 753 Decimal to Binary.
  6. Homework H4.6: Convert 100111011 Binary to Decimal.
  7. Homework H4.7: Carry out the binary addition:
     00101110
    +01011011
    ---------
    
  8. Homework H4.8: Given the unsigned char 10001011 Find the decimal equivalent.
  9. Homework H4.9: Given the char 10001011 Find the decimal equivalent.
  10. Homework H4.10: Given the char 00001011 Find the decimal equivalent.
  11. Homework H4.11: Given the decimal value -113, find its char bit pattern.
  12. Homework H4.12: A printer has associated with it an integer variable
    int ctrl;
    
    Its 8th bit controls whether or not to allow revese printing (from right to left). Write code to set the 8th bit and allow reverse printing.
  13. Homework H4.13: A continuation of the previous problem. Write code that clears bit 10 of variable ctrl.
  14. Homework H4.14: Given int x = 23;. What is the value of the expression
       (x << 3) + (x << 1)
    
  15. Homework H4.15: Two variables:
      char c;
      int lowerCaseCount=0;
    
    You are to write a statement that increases lowerCaseCount by 1 if character c contains a lower case letter.
  16. Homework H4.16: Page 6 (More Control) has code that uses the switch construct to count the number of vowels in the string stored in array str. Replace the switch with an if construct:
       if  (....) 
         vCount++;
       else 
         nonVCount++; 
    
    Your job is to figure out what goes between the parentheses.