1a. true
1b. true
1c. true
1d. true
1e. false
1f. true
1g. false
1h. division by 0 error
1i. true
1j. division by 0 error
1k. false
1l. true
2. while or if-else
3. My incorrect answer: (2 < x) && (x<3)
Correct answer: (2 < x) < 3. Since Boolean expression is either true or false which converts to 1 or 0 & 1 or 0 are always < 3 this statement is always true.
4. no, due to short-circuit evaluation
5.
Start
Hello from the second if.
End
Start again
End again
6. large
7. small
8. medium
9.
Start
Second output
End
10.
Start
Second output
End
11.
Start
100
End
12.
int n = 0;
if (n < 0)
	cout << "1st output\n";
else if (0 <= n) && (n <= 100)
	cout << "2nd output\n";
else ( n > 100)
	cout << "3rd output\n";
13. 3 2 1 0
14. 2 1 7 5
15. Roast worms
16. Onion ice cream
17.
Chocolate ice cream
Onion ice cream
18. Bon appetit
19. 42 22
20.
1
1
2
1 was original answer, 2 is correct answer (I failed to realize x2 superceded x1)
3
2
1
21. 2 1 0
22. 2 1
23. 1 2 3 4
24. 1 2 3
25. 2 4 6 8 
26.
Hello 10
Hello 8
Hello 6
Hello 4
Hello 2
27.
sample 2
sample 1.5
sample 1
sample .5
28a. for
28b. while
28c. while
28d. do-while
29a.
for (int i = 1; i <= 10; i++)
{
	if (i < 5 && i != 2)
	cout << 'X';
}
29b.
for (int i = 1; i <= 10; i+=3;)
cout << 'X';
29c.
for (long m = 100; m < 1000; m+=100;)
cout << 'X';
30. 1024 10
31. 1024 1, extra semicolon in the for loop causes the loop body to nothing (skipped)
32. infinite loop, the boolean expression will always be true
33. 4 3 End of loop.
34. 4 3
35. Break statement exits a loop statement. Break statement may be used in any form of loop.
36.
#include <iostream>
using namespace std;
void main()
	{
		for (int i = 1; i <= 10; i++)
		cout << "Hello\n";
	}
37.
#include <iostream>
using namespace std;
void main()
{
	cout << "This program reads in even numbers &\n"
		 << "will compute the total of the numbers\n"
		 << "entered.\n"
		 << "Enter even numbers separated by spaces.\n"
		 << "To end input enter a negative number.\n";

	int total = 0, number;

	cin >> number;
	
	while (number >= 0)
	{
		total+=number;
		cin >> number;
	}
	cout << "Sum of all even numbers entered is " << total << endl;
}
38. The first loop repeats 10 times & nested loop 10 times for each iteration of first loop. The output will be 100 answers of n (1 through 10) * m (10 through 1 each time n changes by 1).
39. insert cout statements for variables to see how they change
40. loops that iterate one more or less than you want
41. metric to english conversion & off-by-one loop error since a fence should have posts on both ends

To CS200 Page