Copyright 1999 by Larry Fuhrer. Pascal Programming Branching, Loops, Predefined Functions.

Slides:



Advertisements
Similar presentations
Decisions If statements in C.
Advertisements

Programming in Visual Basic
Computer Science 101 Overview of Algorithms. Example: Make Pancakes Prepare batter Beat 2 eggs Add 1 tablespoon of brown sugar Add 1 cup of milk Add 2.
Program Development Procedures 1.Program definition clearly define what the problem is. clearly define Input and output data (types, precision, units used)
System Concepts for Process Modeling  Process Concepts  Process Logic  Decomposition diagrams and data flow diagrams will prove very effective tools.
J. Michael Moore Structured Programming CPSC 110 Drawn from James Tam's material.
ALGOL 60 Design by committee of computer scientists: Naur, Backus, Bauer, McCarthy, van Wijngaarden, Landin, etc. Design by committee of computer scientists:
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 3, Lecture 2.
Control Flow C and Data Structures Baojian Hua
J. Michael Moore Structured Programming CSCE 110 Drawn from James Tam's material.
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.
Ways to solve problems Top down approach – Break problem up into smaller problems Bottom up approach – Solve smaller problem and then add features – Examples:
4/16/2007Declare a Schema File I1. 4/16/2007Declare a Schema File I2 Declare a Schema File A collection of semantic validation rules designed to constrain.
Introduction to PL/SQL
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
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.
Fundamentals of Python: From First Programs Through Data Structures
1 I.Introduction to Algorithm and Programming Algoritma dan Pemrograman – Teknik Informatika UK Petra 2009.
Fundamentals of Python: First Programs
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Structural Program Development: If, If-Else Outline.
Copyright 1999 by Larry Fuhrer. Pascal Programming Getting Started...
CS 331, Principles of Programming Languages Chapter 2.
Mr. Dave Clausen1 La Cañada High School Chapter 6: Repetition Statements.
Grading Exams 60 % Lab 20 % Participation 5% Quizes 15%
CS 153: Concepts of Compiler Design October 5 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Software Engineering Chapter 3 CPSC Pascal Brent M. Dingle Texas A&M University.
CPS120: Introduction to Computer Science Decision Making in Programs.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 6, Lecture 1 (Monday)
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
Basic Program Construction
Programming, an introduction to Pascal
5-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
Introduction to Computer Programming
Basic Programming Lingo. A program is also known as a  Sequence of instructions  Application  App  Binary  Executable.
1 Program Planning and Design Important stages before actual program is written.
Python 101 Dr. Bernard Chen University of Central Arkansas PyArkansas.
Pascal Programming Pascal Loops and Debugging. Pascal Programming Pascal Loops In our first brush with the while do loops, simple comparisons were used.
Control Flow Computer Engineering Department Java Course Asst. Prof. Dr. Ahmet Sayar Kocaeli University - Fall 2014.
Time Complexity. Solving a computational program Describing the general steps of the solution –Algorithm’s course Use abstract data types and pseudo code.
CSCI 161 Lecture 7 Martin van Bommel. Control Statements Statements that affect the sequence of execution of other statements Normal is sequential May.
CS 331, Principles of Programming Languages Chapter 2.
COIT29222 Structured Programming 1 COIT29222-Structured Programming Lecture Week 02  Reading: Textbook(4 th Ed.), Chapter 2 Textbook (6 th Ed.), Chapters.
ERRORS. Types of errors: Syntax errors Logical errors.
Week 4 Program Control Structure
Pascal Programming Making decisions - Selection Statements National Certificate Unit 4 Carl Smith.
Why Repetition? Read 8 real numbers and compute their average REAL X1, X2, X3, X4, X5, X6, X7, X8 REAL SUM, AVG READ *, X1, X2, X3, X4, X5, X6, X7, X8.
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.
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
Imperative Programming Statements and invariants.
C++ for Engineers and Scientists Second Edition Chapter 4 Selection Structures.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. 4 Simple Flow of Control.
15.1 More About High-Level Programming Languages Syntax and Semantics Each programming language contains its own rules for both syntax and semantics. Syntax.
7 - Programming 7J, K, L, M, N, O – Handling Data.
Basic concepts of C++ Presented by Prof. Satyajit De
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Chapter 10 Programming Fundamentals with JavaScript
Sequence, Selection, Iteration The IF Statement
Chapter 10 Programming Fundamentals with JavaScript
Problem Solving Techniques
Topics discussed in this section:
CS1100 Computational Engineering
Algorithms & Pseudocode
Structured Program
3 Control Statements:.
Computer Science Core Concepts
ICT Gaming Lesson 2.
Simple Branches and Loops
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.
REPETITION Why Repetition?
Presentation transcript:

Copyright 1999 by Larry Fuhrer. Pascal Programming Branching, Loops, Predefined Functions

Copyright 1999 by Larry Fuhrer. Pascal Programming The if-then-else statement – a branching method Chooses between two alternative courses of action Syntax: if expression1 operator expression2 then statement1 else statement2 Operators: = equal to; <> not equal to; greater than; = greater than or equal to.

Copyright 1999 by Larry Fuhrer. Pascal Programming Note – the if-then-else does not place a semi-colon (;) at the end of the then statement... In Turbo Pascal upper case X and lower case x are not the same character! REAL does not have an exact value... therefore testing the equal = or not equal <> has little value.

Copyright 1999 by Larry Fuhrer. Pascal Programming Syntax...rules describing how to write, punctuate statements, declaration and other language constructs. Syntax rules are RIGID... You need a precise description of the syntax or grammar as you write.

Copyright 1999 by Larry Fuhrer. Pascal Programming Compound Statement A compound statement acts as a single statement e g: (ignore my outline marks) –begin writeln (‘You pass with a score of ‘); writeln (Score – 60, ‘points to spare. ‘) –end

Copyright 1999 by Larry Fuhrer. Pascal Programming While do statements – a looping method A loop repeats statement or group of statements –e g: while Number > 0 do –While the number is greater than zero continue to do the following... Syntax: while expression1 operator expression2 do body Each time through the loop is an interation A while statement must be initialized –e g: Number := 0

Copyright 1999 by Larry Fuhrer. Pascal Programming Predefined Functions... Pascal includes predefined functions. Sqrt or square root is one example The function requires an argument. –e g: sqrt (4) {the argument is 4} The function may be included in a formula. Continue...

Copyright 1999 by Larry Fuhrer. Pascal Programming Predefined functions continued... ln computes the natural logarithm There is no exponential operator in Pascal

Copyright 1999 by Larry Fuhrer. Pascal Programming Iterative enhancement – create a simple program and then add features and refinement to make it more powerful. Run-time errors appear when the program is run. They seem to be hidden when you debug the program. Overflow errors arise when numbers get too small or too large. With logical errors, the program will run but not produce intended results.