Presentation is loading. Please wait.

Presentation is loading. Please wait.

Midterm1 answers: Page 1 1 a6 b6 c0 2 ***. Midterm1 answers: Page 2 A)a. 53b. 44c. 13d. 75e. 77 B)a. 53b. 17c. 33 / 44d. 13e. 75 C)a. ‘5’b. ‘3’c. ‘ ‘d.

Similar presentations


Presentation on theme: "Midterm1 answers: Page 1 1 a6 b6 c0 2 ***. Midterm1 answers: Page 2 A)a. 53b. 44c. 13d. 75e. 77 B)a. 53b. 17c. 33 / 44d. 13e. 75 C)a. ‘5’b. ‘3’c. ‘ ‘d."— Presentation transcript:

1 Midterm1 answers: Page 1 1 a6 b6 c0 2 ***

2 Midterm1 answers: Page 2 A)a. 53b. 44c. 13d. 75e. 77 B)a. 53b. 17c. 33 / 44d. 13e. 75 C)a. ‘5’b. ‘3’c. ‘ ‘d. ‘4’e. ‘4’

3 Midterm1 answers: Page 3 integer11 integer0 real4.0 integer19 FOR Index := 1 TO 6 DO write(‘*’);

4 Midterm1 answers: Page 3 (con’t) 16 Number2 15 1 Number2 - Number1

5 Last Class IF / THEN / ELSE comparison expressions Boolean Operators

6 We will not cover the following sections in class: –7.2 –7.4 –7.8(we will discuss the design topics) You ARE responsible for knowing the topics covered in these sections. The topics are covered in the other sections of the chapter. However, these sections contain very good examples and you should study them.

7 Boolean Operators: NOT If NOT (BoolEx) THEN writeln(‘BoolEx is FALSE’); The NOT Operator simply reverses the boolean value of the boolean expression that appears immediately to its right. NOT (a <= 2) OR (b = 2) will evaluate to TRUE if a is greater than 2 and / or b =2.

8 Pascal Sets In Pascal you can define sets by placing a group of ‘elements’ of any single ordinal type between brackets. –[‘A’, ‘E’, ‘I’, ‘O’, ‘U’] –[1..9]{all values between 1 and 9}

9 Pascal Sets: The IN operator The boolean operator IN is used to test whether an item is an element of a set. FOR Letter := ‘A’ TO ‘Z’ DO IF Letter IN [‘A’, ‘E’, ‘I’, ‘O’, ‘U’] THEN write(letter);

10 Precedence Priority Operator(s) topparenthesis thenNOT (note: unary) thenAND, *, /, DIV, MOD thenOR, +, - then=, <>, >, =, <=, IN

11 Section 7.7 Skip for now we may revisit include files

12 Section 7.8 Per first slide, we will discuss the design issues in another class. You should read and “grok” this section’s example

13 Nested IF Statements When you nest IF statements, an else will match to the closest ‘non-matched’ IF. IF Age >= 21 THEN IF Age <= 35 THEN writeln(‘come in’) ELSE writeln(‘Do you know this is a college bar’); The ELSE will match with IF AGE <= 35

14 Multiple Alternative IF-THEN-ELSE The multiple IF-THEN-ELSE is a multiway switch that allows you to choose only one of many options. IF A < 10 THEN … ELSE IF A < 15 THEN … ELSE...

15 Homework due 3-28-2000 On Marateck’s website homework #5 The assignment is like a “version 2.0” of the one due today. You must change your program to accept input from the user, print more letters, and pass a value parameter to determine the placement of your vertical line. (we will discuss CASE statements next class - it not not necessary for assignment)


Download ppt "Midterm1 answers: Page 1 1 a6 b6 c0 2 ***. Midterm1 answers: Page 2 A)a. 53b. 44c. 13d. 75e. 77 B)a. 53b. 17c. 33 / 44d. 13e. 75 C)a. ‘5’b. ‘3’c. ‘ ‘d."

Similar presentations


Ads by Google