<commit_before>---
num: "h04"
desc: "Homework 4"
ready: false
assigned: 2016-10-04 14:00:00.00-7:00
due: 2016-10-06 14:00:00.00-7:00
---
{% include no_staples_box.html %}
Read Chapter 2 and Ch 3.1 (If you do not have a copy of the textbook yet, there is one on reserve at the library under "COMP000-STAFF - Permanent Reserve").

<ol markdown="1">
1.	(1 pts) What is flow control?
  <div style="margin-bottom:4em"></div>

2.	(1 pts) Which Boolean operator, when used with 2 logic expressions, yields TRUE only if both expressions are TRUE?
  <div style="margin-bottom:4em"></div>

3.	(1 pts) What is wrong with this C++ expression?
  <div style="margin-bottom:1em"></div>
  <div markdown="1">
```
if (size = 4)
   cout << "The size is too small";
```
  </div>
  <div style="margin-bottom:4em"></div>

4.	(2 pts) Write an if-else statement that outputs the word High if the value of the variable score is greater than 100 and Low if the value of score is at most 100? The variable score is of type int. 
  <div style="margin-bottom:4em"></div>

5.	(3 pts) Show the output of this code if x is of type int.
<div markdown="1">
```
x = 10;
while ( x > 0) {
   cout << x << endl;
   x = x – 3;
 }
```
</div> 
  <div class="pagebreak"></div>

6.	(3 pts) Write a while loop that prints out these 11 lines: 
<div markdown="1">
```
COUNTDOWN TO ZERO: 10
COUNTDOWN TO ZERO: 9
...
COUNTDOWN TO ZERO: 1
COUNTDOWN TO ZERO: LIFT OFF!
```
</div>
<div style="margin-bottom:10em"></div>

7.	(12 pts)  What is the result (i.e. TRUE or FALSE) of the following Boolean operations in C++, given that: x = 7, y = 10, z = 12
	<div style="margin-bottom:0em"></div>
<div markdown="1">
	a) (x == 6)



	b) !(y > 0)



	c) ((x == 6) || (y < 20))
	
	
	
	d) ((x >= 3) && (z <= 12))
	
	
	
	e) ((x > y) && (y < z))
	
	
	
	f) ((!(x < z) || (y > z)) && (z == 12) && (y == 10))
	
	
	
	
	.	
</div>
<div style="margin-bottom:2em"></div>


8.	(20 pts) Write a program that first asks for the user's name, then asks the user to pick a shape to find the area to: a rectangle, a triangle, a trapezoid, or a circle. Based on the user's choice, the program then gets the pertinent parameters from user input, then it calculates the area of the shape, and finally, it reports the answer back to the user.
	<div style="margin-bottom:1em"></div>
	Plan this out well: what are the variables that you'll need? What type will each be? You MUST:
	<div style="margin-bottom:0em"></div>
	.....a) Make your program easy to read and understand. This includes the use of comments in the program to tell us what you're doing.
	<div style="margin-bottom:0em"></div>
	.....b) Declare at least one constant in the program.
	<div style="margin-bottom:0em"></div>
	.....c) Format your answers so that they are readable on the display. This means consider your use of "\n" characters and the proper formatting of decimal places in the displayed numbers to the user.
	<div style="margin-bottom:0em"></div>
	.....d) Test this program out by compiling it and running it the same way you do this with lab assignments.
	<div style="margin-bottom:1em"></div>
	When you are sure that you have a working program, attach a print out of it to this homework sheet - REMEMBER TO PUT YOUR FULL NAME AND ID# ON THIS SHEET! You will be graded for programming style as well as for functionality correctness.
<commit_msg>Update h04.md<commit_after>---
num: "h04"
desc: "Homework 4"
ready: false
assigned: 2016-10-04 14:00:00.00-7:00
due: 2016-10-06 14:00:00.00-7:00
---
{% include no_staples_box.html %}
Read Chapter 2 and Ch 3.1 (If you do not have a copy of the textbook yet, there is one on reserve at the library under "COMP000-STAFF - Permanent Reserve").

<ol markdown="1">
1.	(1 pts) What is flow control?
  <div style="margin-bottom:4em"></div>

2.	(1 pts) Which Boolean operator, when used with 2 logic expressions, yields TRUE only if both expressions are TRUE?
  <div style="margin-bottom:4em"></div>

3.	(1 pts) What is wrong with this C++ expression?
  <div style="margin-bottom:1em"></div>
  <div markdown="1">
```
if (size = 4)
   cout << "The size is too small";
```
  </div>
  <div style="margin-bottom:4em"></div>

4.	(2 pts) Write an if-else statement that outputs the word High if the value of the variable score is greater than 100 and Low if the value of score is at most 100? The variable score is of type int. 
  <div style="margin-bottom:4em"></div>

5.	(3 pts) Show the output of this code if x is of type int.
<div markdown="1">
```
x = 10;
while ( x > 0) {
   cout << x << endl;
   x = x – 3;
 }
```
</div> 
  <div class="pagebreak"></div>

6.	(3 pts) Write a while loop that prints out these 11 lines: 
<div markdown="1">
```
COUNTDOWN TO ZERO: 10
COUNTDOWN TO ZERO: 9
...
COUNTDOWN TO ZERO: 1
COUNTDOWN TO ZERO: LIFT OFF!
```
</div>
<div style="margin-bottom:10em"></div>

7.	(12 pts)  What is the result (i.e. TRUE or FALSE) of the following Boolean operations in C++, given that: x = 7, y = 10, z = 12
	<div style="margin-bottom:0em"></div>
<div markdown="1">
	a) (x == 6)



	b) !(y > 0)



	c) ((x == 6) || (y < 20))
	
	
	
	d) ((x >= 3) && (z <= 12))
	
	
	
	e) ((x > y) && (y < z))
	
	
	
	f) ((!(x < z) || (y > z)) && (z == 12) && (y == 10))
	
	
	
	.	
</div>
<div style="margin-bottom:2em"></div>


8.	(20 pts) Write a program that first asks for the user's name, then asks the user to pick a shape to find the area to: a rectangle, a triangle, a trapezoid, or a circle. Based on the user's choice, the program then gets the pertinent parameters from user input, then it calculates the area of the shape, and finally, it reports the answer back to the user.
	<div style="margin-bottom:1em"></div>
	Plan this out well: what are the variables that you'll need? What type will each be? You MUST:
	<div style="margin-bottom:0em"></div>
	.....a) Make your program easy to read and understand. This includes the use of comments in the program to tell us what you're doing.
	<div style="margin-bottom:0em"></div>
	.....b) Declare at least one constant in the program.
	<div style="margin-bottom:0em"></div>
	.....c) Format your answers so that they are readable on the display. This means consider your use of "\n" characters and the proper formatting of decimal places in the displayed numbers to the user.
	<div style="margin-bottom:0em"></div>
	.....d) Test this program out by compiling it and running it the same way you do this with lab assignments.
	<div style="margin-bottom:1em"></div>
	When you are sure that you have a working program, attach a print out of it to this homework sheet.
	You will be graded for programming style as well as having a functionally correct program.</b>
	<div style="margin-bottom:0em"></div>
	<b>PLEASE REMEMBER TO PUT YOUR FULL NAME AND ID# ON THIS SHEET!</b>
	
</ol>
{'fraction_non_alphanumeric': 0.1391561806069578, 'fraction_numerical': 0.03597335307179867, 'mean_word_length': 3.507004669779853, 'pattern_counts': {'":': 0, '<': 107, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4061429', 'n_tokens_mistral': 2472, 'n_tokens_neox': 2228, 'n_words': 1019}