CS 1713 Introduction to Computer Science, Spring 2008 Quiz 2 Comments

20 people took this quiz. Seven people got 1 point and 3 people got 2 points.

  1. Write a program segment that increments the integer variable count if the integer variable value is 2 or 3.
       if ( (value == 2) || (value == 3))
          count++;
    
  2. Write a program segment that uses a loop to set the double variable sum to the sum of the square roots of the integers between 1 and 1000, inclusive.
    Hint: use Math.sqrt().
       sum = 0;
       for (int i=1; i<=1000; i++)
          sum = sum + Math.sqrt(i);