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.

Slides:



Advertisements
Similar presentations
1 Chapter Five Selection and Repetition. 2 Objectives How to make decisions using the if statement How to make decisions using the if-else statement How.
Advertisements

Selection (decision) control structure Learning objective
Pascal Programming Today Chapter 4 1 »Conditional statements allow the execution of one of a number of possible operations. »Conditional statements include:
Slide 1 Summary Two basic concepts: variables and assignments Some C++ practical issues: division rule, operator precedence  Sequential structure of a.
Decisions (Conditional Programming) Chapter 5 (Sec. 5.1 & 5.2)
1 9/24/07CS150 Introduction to Computer Science 1 Relational Operators and the If Statement.
Basic Elements of Programming A VB program is built from statements, statements from expressions, expressions from operators and operands, and operands.
If Statements. COMP104 If / Slide 2 Three Program Structures * Sequence - executable statements which the computer processes in the given order * Choice.
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.
James Tam Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action.
1 CS150 Introduction to Computer Science 1 Relational Operators and the If Statement 9/22/08.
James Tam Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action.
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
Visual C++ Programming: Concepts and Projects
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 4 Making.
James Tam Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action.
12-2 Know how if and switch C statements control the sequence of execution of statements. Be able to use relational and logical operators in the conditional.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 4 Decision Structures and Boolean Logic.
Decision Structures and Boolean Logic
Using the selection structure (Unit 7) Visual Basic for Applications.
CHAPTER 4: CONDITIONAL STRUCTURES Introduction to Computer Science Using Ruby (c) 2012 Ophir Frieder et al.
Programming Fundamentals. Today’s lecture Decisions If else …… Switch Conditional Operators Logical Operators.
Control Structures – Selection Chapter 4 2 Chapter Topics  Control Structures  Relational Operators  Logical (Boolean) Operators  Logical Expressions.
Lecture Set 5 Control Structures Part A - Decisions Structures.
Chapter 4: Making Decisions. Understanding Logic-Planning Tools and Decision Making Pseudocode – A tool that helps programmers plan a program’s logic.
1 Conditions Logical Expressions Selection Control Structures Chapter 5.
Decision II. CSCE 1062 Outline  Boolean expressions  switch statement (section 4.8)
Agenda Exam #1 Review Modulus Conditionals Boolean Algebra Reading: Chapter Homework #5.
Chapter 3 Selections Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved
Practice 1.2 Answers
C STRUCTURES. A FIRST C PROGRAM  #include  void main ( void )  { float height, width, area, wood_length ;  scanf ( "%f", &height ) ;  scanf ( "%f",
Selection Boolean What is Boolean ? Boolean is a set with only two values : –true –false true and false are standard identifiers in Pascal, called Boolean.
Making Decisions Chapter 5.  Thus far we have created classes and performed basic mathematical operations  Consider our ComputeArea.java program to.
PROBLEM SOLVING & ALGORITHMS CHAPTER 5: CONTROL STRUCTURES - SELECTION.
Chapter 5 Logic; Got Any?. Flow of Control The order in which the computer executes statements in a program Control Structure A statement used to alter.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Selection Statements Selection Switch Conditional.
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X1 Chapter 3 Control Statements.
1 09/15/04CS150 Introduction to Computer Science 1 Life is Full of Alternatives Part 2.
Copyright 2003 Scott/Jones Publishing Making Decisions.
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X1 Chapter 3 Control Statements.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 5, Lecture 1 (Monday)
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 4 Making Decisions.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
Chapter 3 Decisions Three control structures Algorithms Pseudocode Flowcharts If…then …else Nested if statements Code blocks { } multi statement blocks.
An Object-Oriented Approach to Programming Logic and Design Chapter 5 Making Decisions.
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
Pascal Programming George Boole, a 19 th Century mathematician, is created with true, false logic. A Boolean expression in Pascal will be true or false.
Chapter 5 – Decision Making. Structured Programming Sequence Selection Repetition yesno yes no.
Lecture 17 If-else statement Nothing is good or bad, but by comparison. Thomas Fuller, Gnomologia.
Today… Operators, Cont. Operator Precedence Conditional Statement Syntax. Winter 2016CISC101 - Prof. McLeod1.
Python Basics.
Lecture 3 Selection Statements
Making Choices with if Statements
Chapter 3 Control Statements Lecturer: Mrs Rohani Hassan
Topics The if Statement The if-else Statement Comparing Strings
The order in which statements are executed is called the flow of control. Most of the time, a running program starts at the first programming statement,
Scripts & Functions Scripts and functions are contained in .m-files
Chapter 6: Conditional Statements and Loops
Control Structures – Selection
Topics The if Statement The if-else Statement Comparing Strings
Relational Operators Operator Meaning < Less than > Greater than
Selection CSCE 121 J. Michael Moore.
Chapter 3:Decision Structures
The System.exit() Method
Lecture Notes – Week 2 Lecture-2
Relational Operators.
Chapter 4: Boolean Expressions, Making Decisions, and Disk Input and Output Prof. Salim Arfaoui.
The Selection Structure
Selection Control Structure
Presentation transcript:

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. ‘4’e. ‘4’

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

Midterm1 answers: Page 3 (con’t) 16 Number Number2 - Number1

Last Class IF / THEN / ELSE comparison expressions Boolean Operators

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.

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.

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}

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);

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

Section 7.7 Skip for now we may revisit include files

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

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

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...

Homework due 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)