Name_______________________
Login___________________SID________
CS 010: Introduction to
Computer Science I
int i = 100; while (i > 0) { cout
<< i * i << ; i--; } cout << endl; for (int i = 100; i > 0; i--) { cout
<< i * i << ; } cout << endl;
a.
TRUE
b. FALSE
int i = 100; while (i > 0) { i--; cout
<< i * i << ; } cout << endl; for (int i = 100; i > 0; i--) { cout
<< i * i << ; } cout << endl;
a. TRUE
b.
FALSE
int main() { for (int i = 0; i < 4; i++) { cout
<< i << ; } cout << i << endl; return 0; }
a. 0 1 2 3 4
b. 0 1 2 3 4 5
c. 1 2 3 4 5
d. 4
e. 5
f. one of the cout statements has a syntax error because of the scope of i
int main() { int i; for (i = 0; i < 4; i++) { cout
<< i << ; } cout << i << endl; return
0; }
a.
0
1 2 3 4
b. 0 1 2 3 4 5
c. 1 2 3 4 5
d. 4
e. 5
f. one of the cout statements has a syntax error because of the scope of i
int x = 10; do { x -= 3; cout
<< x << ; } while (x > 0) ; // do while x is greater than 0 cout << x << endl;
int x = 10; do { x -= 3; cout
<< x << ; } while (x > 10) ; // do while x is greater than 10 cout << x << endl;
Use the following code for the next 2 questions
void f1(int& x)
{
x = 100;
}
void f2(int a, int& b)
{
a = a * b;
b = 12;
if (b < a)
{
f1(b);
}
else
{
f1(a);
}
}
int main()
{
int num1 = 2;
int num2 = 4;
f2(num1, num2);
cout << num1 << << num2 << endl; //OUTPUT 1
num1 = 4;
num2 = 5;
f2(num1, num2);
cout << num1 << << num2 << endl; //OUTPUT 2
return 0;
}