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

21 people took this quiz. Eight people got 1 point and 2 people got 2 points.

A program segment is not a method.
It does not have a name and it does not return anything.
It does not have to declare or create the variables mentioned in the problem
    (unless it explicitly says to declare them).
It should only do what the problem states and no more.
It should not print anyting unless you are explictly told to do so.

  1. Write a program segment that sets the boolean variable found to true if the integer variable num is between 1 and 100, inclusive.
       if ( (num >=1) && (num <= 100))
          found = true;
    
  2. Write a program segment that uses a loop to set the integer variable sum to the sum of the squares of the integers between 1 and 1000, inclusive.
       sum = 0;
       for (int i=1; i<=1000; i++)
          sum = sum + i*i;