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.

Slides:



Advertisements
Similar presentations
Chapter 2 Flow of Control. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 2-2 Learning Objectives Boolean Expressions Building, Evaluating.
Advertisements

Introduction to C Programming
Pascal Programming Today Chapter 4 1 »Conditional statements allow the execution of one of a number of possible operations. »Conditional statements include:
Program CheckPass; var TestScore, ExamScore : integer; FinalScore : real; Status : string; begin write(‘Enter the Test score:’); readln(Testscore); write(‘Enter.
Overview Program flow Decision / branching / selection structures True & False in Python Comparison operators & Boolean expressions if … if … else if …
Basic Elements of Programming A VB program is built from statements, statements from expressions, expressions from operators and operands, and operands.
Selection Statements choice of one among several blocks of code Java supports 3 kinds of selection statements: if statement – selects one block or leaves.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 4: Control Structures I (Selection)
true (any other value but zero) false (zero) expression Statement 2
1 CS 105 Lecture 4 Selection Statements Wed, Jan 26, 2011, 6:05 pm.
School of Computing Science CMT1000 Ed Currie © Middlesex University 1 CMT1000: Introduction to Programming Ed Currie Lecture 5B: Branch Statements - Making.
1 Lecture 7:Control Structures I (Selection) Introduction to Computer Science Spring 2006.
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
Chapter 4: Control Structures: Selection
Admin Office hours 2:45-3:15 today due to department meeting if you change addresses during the semester, please unsubscribe the old one from the.
Quiz 1 Exam 1 Next Week. Nested if Statements if (myGrade >= 80) if (myGrade >= 90) cout
EGR 2261 Unit 4 Control Structures I: Selection  Read Malik, Chapter 4.  Homework #4 and Lab #4 due next week.  Quiz next week.
CSci 125 Lecture 10 Martin van Bommel. Simple Statements Expression followed by semicolon Assignments total = n1 + n2; Function calls printf(”Hello.\n”);
1 The CONST definition CONST Pi = , City = ‘New York’; Constant identifiers are used when you do not want the value of an identifier to change why.
Chapter 3: Data Types and Operators JavaScript - Introductory.
Chapter 4: Control Structures I (Selection). Objectives In this chapter, you will: – Learn about control structures – Examine relational operators – Discover.
Control Structures – Selection Chapter 4 2 Chapter Topics  Control Structures  Relational Operators  Logical (Boolean) Operators  Logical Expressions.
More on Input Output Input Stream : A sequence of characters from an input device (like the keyboard) to the computer (the program running). Output Stream.
Dr. Yang, QingXiong (with slides borrowed from Dr. Yuen, Joe) LT3: Conditional Statements CS2311 Computer Programming.
Chapter 4: Control Structures I (Selection). Objectives In this chapter, you will: – Learn about control structures – Examine relational and logical operators.
Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else):
1 Conditions Logical Expressions Selection Control Structures Chapter 5.
1. We’ve learned that our programs are read by the compiler in order, from top to bottom, just as they are written The order of statement execution is.
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.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 6, Lecture 1 (Monday)
Introduction to Programming Languages S1.3.1Bina © 1998 Liran & Ofir Introduction to Programming Languages Programming in C.
CS-1030 Dr. Mark L. Hornick 1 C++ Language Basic control statements and data types.
Copyright © 2012 Pearson Addison-Wesley. All rights reserved. CIS_IS20_CSLO 1. Explain computer programming concepts CSLO1.6. Explain the purpose of general.
1 2. Program Construction in Java. 2.4 Selection (decisions)
Chapter 7 Selection Dept of Computer Engineering Khon Kaen University.
Programming 1 DCT 1033 Control Structures I (Selection) if selection statement If..else double selection statement Switch multiple selection statement.
1 © 2002 John Urrutia. All rights reserved. Qbasic Chapter 4 IF Statements and READ & DATA.
Pascal Programming Written by Leung King Yung. Simple Program 1 begin end.
CSC1201: Programming Language 2 Lecture 1 Level 2 Course Nouf Aljaffan (C) CSC 1201 Course at KSU1.
1 Chapter 4, Part 1 If Control Construct A mechanism for deciding whether an action should be taken JPC and JWD © 2002 McGraw-Hill, Inc. Modified by S.
Quiz 3 is due Friday September 18 th Lab 6 is going to be lab practical hursSept_10/exampleLabFinal/
C# Operator Overloading and Type Conversions C#.NET Software Development Version 1.0.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
Chapter 4: Control Structures I (Selection). Objectives In this chapter, you will: – Learn about control structures – Examine relational and logical operators.
Copyright 1999 by Larry Fuhrer. Pascal Programming Branching, Loops, Predefined Functions.
Fundamental Programming Fundamental Programming More Expressions and Data Types.
Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else):
C++ for Engineers and Scientists Second Edition Chapter 4 Selection Structures.
Chapter 4: Control Structures I (Selection). Objectives In this chapter, you will: – Learn about control structures – Examine relational operators – Discover.
Definition of the Programming Language CPRL
Written by Al.So. Software solutions
Selection (also known as Branching) Jumail Bin Taliba by
Sequence, Selection, Iteration The IF Statement
Bill Tucker Austin Community College COSC 1315
Control Structures Combine individual statements into a single logical unit with one entry point and one exit point. Used to regulate the flow of execution.
A mechanism for deciding whether an action should be taken
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Flow of Control.
2.0 FUNDAMENTALS OF JAVA PROGRAMMING LANGUAGE
Control Structures – Selection
JavaScript conditional
Expression Review what is the result and type of these expressions?
C++ Data Types Data Type
CSC215 Lecture Flow Control.
Chapter 4: Control Structures I (Selection)
JavaScript conditional
CMPE 152: Compiler Design February 21 Class Meeting
CSC215 Lecture Control Flow.
Flow of Control Flow of control is the order in which a program performs actions. Up to this point, the order has been sequential. A branching statement.
Conditionals.
Presentation transcript:

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. Compound expressions are created with the operators and, or, not. Since interlocking expressions –e g: a>b>c—are not allowed in Pascal. So, Boolean expressions are combined to accomplish the same end result. continue...

Pascal Programming And... Expects this and that condition will both be met for the statement to be true. Or...Expects that one or both conditions will be met for the statement to be true. Not... Changes true to false and false to true. Precedence affects these operators– they are settled (1) not, (2) and (3) or. continue...

Pascal Programming An expression with and yields true only when both are true. If one or both conditions are false it yields false. An expression with or yields true unless both conditions are false. An expression with not yields true when the expression is not(true). The Turbo compiler uses short-circuit evaluation—evaluating only as many conditions as may be needed to determine the value.

Pascal Programming Using Sets... A Boolean can evaluate a set. Syntax...Ans in [‘A’, ‘B’] –in is a reserved word. A Set contains a list of constants separated by commas and enclosed in square brackets. The set may be used as a sub-part of a Boolean expression. (Not precedes the expression.)

Pascal Programming A variable can contain a Boolean expression but it must be type Boolean. Variables with type Boolean are declared just like other variables. A function can return a type Boolean. This can make it read more like natural language.

Pascal Programming Multiway branching can be accomplished with nested if-then-else statements... e g : if N > 25 then If O > than 5 then – or Case statements. continue...

Pascal Programming Syntax... (The Label List follows the of.) –Case Grade of ‘A’, ‘B’: writeln(‘Very Good!’); “C”: writeln (‘Passing’); ‘D’, ‘F’: writeln (‘Too bad!’); else Writeln(‘No Grade was posted.’) End Case statements can be controlled by types integer or char but not real or string. The else can be omitted with an effect similar to omitting it on the if-then-else statement.