Name_______________________
Login___________________SID________
CS 010: Introduction to
Computer Science I
for
(int i = m; i <= n; i++)
{
cout << “*“;
}
a. 0
b. 1
c. n - 1
d. n - m
e. n + m
f.
n
- m + 1
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= n; j++)
{
cout << “*“;
}
cout << endl;
}
a. 0
b. 1
c.
m
* n
d. m + n
e. (m - 1) + (n - 1)
f. (m + 1) * (n + 1)
a. 0
b. 1
c. m
d. n
e. m - 1
f. m * n
do
{
cout << n << “ “;
n++;
}
while (n <= 10);
a. If n is less than 10, this will be an infinite loop.
b. This is a syntax error.
c.
This
will output the integers from n to 10 if n is less or equal to 10.
d. Nothing happens. The while loop is skipped.
while
(n <= 10);
{
cout << n << “ “;
n++;
}
a.
If
n is less than 10, this will be an infinite loop.
b. This is a syntax error.
c. This will output the integers from n to 10 if n is less or equal to 10.
d. Nothing happens. The while loop is skipped.
int
n = 11;
do
{
cout << n << “ “;
n++;
}
while (n < 10);
vector<int>
v(n);
v[0]
= 10;
v[1]
= s;
v[2]
= “s“;
b. No, we need to know more about the program this code came from to say it is definitely a syntax error.