Name_______________________
Login___________________SID________
CS 010: Introduction to
Computer Science I
int x = 10;
while (x < 20)
{
cout << x << “ “;
x = x + 3;
}
a. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
b. 10 11 12 13 14 15 16 17 18 19 20
c. 10 12 14 16 18 20
d. 10 13 16 19 22
e.
10
13 16 19
f. 13 16 19 22
int x = 10;
int sum = 0;
while (x < 20)
{
sum = sum + x;
x = x + 5;
}
cout << sum;
a. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
b. 10 15 20
c. 10 15
d. 15
e.
25
f. None of the above
a.
TRUE
b. FALSE
Circle c(Point(0,0), 5.0);
int count = 0;
while (c.get_center().get_x() < 3)
{
c.move(2,1);
count++;
}
cwin << Message(Point(0,0), count);
a. 0
b. 1
c.
2
d. 3
e. 4
f. 5
int entry = 0;
int count = 0;
int sum = 0;
cout << “Enter positive integers (type negative integer to quit)\n”;
cin >> entry;
while (entry >= 0)
{
sum = sum + entry;
cin >> entry;
count++;
}
cout << sum / count;
int max(int first, int second)
{
if (first > second)
{
return first;
}
else
{
return second;
}
}
Which of the following function invocations (calls) is valid? Assume the max function is invoked (called) from within the main function and that int variables f and s have been declared and initialized before the max function is invoked (called).
void do_something(int value)
{
cout << value * value / 2;
}