Test 2 CSCI 130 Spring 2003


  1. (10 points) For the data types float and int

  2. (6 points) What is type casting? What is coercion? Which should be employed when writing programs? Why?

  3. (5 points) What is operator presidence? How is operator presidence overridden by the use of parenthesis? Give an example.

  4. (4 points) Trace the execution of the following code segment
    int a, b, c, d;
    float x=2.0;
    
    a = 4;
    b = a/x;
    c = y/a;
    x = 5/3;
       
  5. (5 points) What is the setw() function? Describe the operation and give examples of the use of this function. (Your examples should include both code and example output to accompany this code).

  6. (3 points) Describe the operation of the following code.
    string letters;
    
    letters = "Hello to you";
    cout << letters.size();
    cout << letters.find("to");
    

  7. (3 points) What is the extraction operator (get from)? Where is it used? Give an example showing how this operator is used.

  8. (9 points) Discuss the behavior of cin >> avar when

  9. (10 points) Trace the following code for the following input lines
         int a;
         char b;
         float c;
         string d;
    
         cin >> d >> a >> b >> c;
    

  10. (10 points) Describe the behavior of the following functions:

  11. (10 points) Compare and contrast Object Oriented Development and Functional Decomposition.