Copyright 1999 by Larry Fuhrer. Pascal Programming Getting Started...

Slides:



Advertisements
Similar presentations
1 C++ Syntax and Semantics The Development Process.
Advertisements

1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Introduction to C++ September 12, Today’s Agenda Quick Review Check your programs from yesterday Another Simple Program: Adding Two Numbers Rules.
C Programming Language 4 Developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories 4 Used to rewrite the UNIX operating system 4 Widely used on UNIX.
James Tam Getting Started With Pascal Programming What is the basic structure of a Pascal Program Variables in Pascal Performing input and output with.
CMT Programming Software Applications
Chapter 2: Input, Processing, and Output
Chapter 2: Introduction to C++.
JavaScript, Third Edition
Chapter 2: Basic Elements of C++
Basic Elements of C++ Chapter 2.
Variables, Constants, Methods, and Calculations Chapter 3 - Review.
Elements of a C++ program 1. Review Algorithms describe how to solve a problem Structured English (pseudo-code) Programs form that can be translated into.
Programming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs.
A Variable is symbolic name that can be given different values. Variables are stored in particular places in the computer ‘s memory. When a variable is.
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.
INTRODUCTION TO ALGORITHMS PROGRAMMING. Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm.
Pascal Programming Strings, Arithmetic operators and output formatting National Certificate – Unit 4 Carl Smith.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Lecture 13 Midterm overview When you know a thing, to hold that you know it, and when you do not know a thing, to allow that you do not know it: this is.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Input, Output, and Processing
Chapter 2: Using Data.
Chapter 2. C++ Program Structure C++ program is a collection of subprograms Subprograms in C++ are called FUNCTIONS Each function performs a specific.
Constants Numeric Constants Integer Constants Floating Point Constants Character Constants Expressions Arithmetic Operators Assignment Operators Relational.
1 INTRODUCTION TO PROBLEM SOLVING AND PROGRAMMING.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
Chapter 2 Overview of C++. 2 Overview  2.1 Language Elements  2.2 Reserved Words & Identifiers  2.3 Data Types & Declarations  2.4 Input/Output 
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
Programming, an introduction to Pascal
1 st semester Basic Pascal Elements อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
CONSTANTS Constants are also known as literals in C. Constants are quantities whose values do not change during program execution. There are two types.
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
Chapter 2 Variables.
CHAPTER 2 C++ SYNTAX & SEMANTICS #include using namespace std; int main() { cout
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
So now we’re programming What do programs do? Manipulate (process) data Math Read files Write to files Create files.
Chapter 3 AS3 Programming. Introduction Algorithms + data structure =programs Why this formula relevant to application programs created in flash? The.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
What will each of the following lines print? System.out.println("number" ); number645 System.out.println("number" + (6 + 4)+ 5); number105 System.out.println(6.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Bill Tucker Austin Community College COSC 1315
Chapter 2 – part b Brent M. Dingle Texas A&M University
Chapter Topics The Basics of a C++ Program Data Types
Topics Designing a Program Input, Processing, and Output
Chapter 6 JavaScript: Introduction to Scripting
BASIC ELEMENTS OF A COMPUTER PROGRAM
The CONST definition CONST Pi = , City = ‘New York’;
Chapter 2: Input, Processing, and Output
ITEC113 Algorithms and Programming Techniques
Basic Elements of C++.
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Lecture2.
Basic Elements of C++ Chapter 2.
INPUT & OUTPUT scanf & printf.
Introduction to C++ Programming
CS111 Computer Programming
Chapter 2 Variables.
Chapter 2: Introduction to C++.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Chapter 2: Input, Processing, and Output
Primitive Types and Expressions
Unit 3: Variables in Java
Variables and Constants
Data Types and Arithmetic in C
Presentation transcript:

Copyright 1999 by Larry Fuhrer. Pascal Programming Getting Started...

Copyright 1999 by Larry Fuhrer. Pascal Begin with an Algorithm A set of instructions that will lead to a solution Instructions take the form of natural language Sometimes called pseudo-code May be a diagram - flowchart

Copyright 1999 by Larry Fuhrer. Pascal To reach a solution... Problem Solving –Define the problem –Design the algorithm –Test the solution Implement the solution –Code in Pascal –Compile –Test the solution

Copyright 1999 by Larry Fuhrer. Pascal Variables – objects that hold data Examples: –X Y Sum N1 N2 Rate Time Bonus Compilers assign memory locations to variables – that memory contains the data Sample... –var N1, N2, Sum: integer;

Copyright 1999 by Larry Fuhrer. Pascal Variables have names called identifiers –Comprised of...a string consisting of letters, numbers or an underscore (_) –Must begin with letter or underscore Reserved words – a type of identifier –e g: begin end var program –Reserved words may only be used as defined by Turbo Pascal

Copyright 1999 by Larry Fuhrer. Pascal Body of the program begin – starts the body which contains statements end. – ends the body of the program Statements – provide the instructions that comprise the body of the program

Copyright 1999 by Larry Fuhrer. Pascal The assignment statement Incorporates the assignment operator := May be read as “gets the value” Example... –Sum := N1 + N2 variable on the left expression on the right

Copyright 1999 by Larry Fuhrer. Pascal Program layout Starts with a program heading –program Getting Started; List the variables –var N1, N2, Sum: integer; Body – bounded by –begin end. Spacing – identifiers or numbers must be separated by a space or punctuation mark Line breaks – very flexible

Copyright 1999 by Larry Fuhrer. Pascal Data types – a category of data Numbers – Integer or Real Integer is a whole number Real is a whole number plus mantissa (fraction) A computation may result in a scientific notation – 9.34E13 Operations include *, -, *, /, div, mod (div divides the first number by the second. mod tells the remainder. Type must be integer.) –Continue...

Copyright 1999 by Larry Fuhrer. Pascal Note... Combine type Real and Integer and you get REAL Dividing (/) yields REAL Operations +, *, - with Integer yield Integer A minus (-) preceding a number does not alter its type

Copyright 1999 by Larry Fuhrer. Pascal Text or letter types char -- holds any ONE keyboard character string -- a series of characters – should be limited FirstName, LastName: string [25]

Copyright 1999 by Larry Fuhrer. Pascal Input and Output To output to the screen we use – writeln – to write and move to a new line write -- writes on the same line –e g: writeln: (‘This begins our answer.’) Numbers in scientific notation can be limited e g: Cost: 6:2 – six space for the answer with two digits to the right of the decimal –Continue...

Copyright 1999 by Larry Fuhrer. Pascal Input data by... readln – reads and goes to next line read – continues on the same line A readln without instruction stops the program because data entry is expected. Generally, writeln and readln will be preferred in a program.

Copyright 1999 by Larry Fuhrer. Pascal Comments Explanatory notes make a program understandable. e g: {This program calculates the interest on a loan.} Punctuation must be complete { }

Copyright 1999 by Larry Fuhrer. Pascal Constants Programs use constant values like interest rates or days in a year. In Pascal constants need to be declared – const –e g: const Year = 365; InterestRate =.075;

Copyright 1999 by Larry Fuhrer. Pascal Summary... Start with an algorithm Use meaningful variable names Declare data type and double check Declare constants with meaningful names Observe ( ) and order of precedence in mathematical expressions Initialize variables Add helpful comments Use prompt lines when calling for data entry