The CONST definition CONST Pi = , City = ‘New York’;

Slides:



Advertisements
Similar presentations
Pascal Syntax. What you have learnt so far writeln() and write(); readln() and read(); variables (integers, strings, character) manipulation of variables.
Advertisements

Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
Program CheckPass; var TestScore, ExamScore : integer; FinalScore : real; Status : string; begin write(‘Enter the Test score:’); readln(Testscore); write(‘Enter.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
Introduction to Computers and Programming Lecture 4: Mathematical Operators New York University.
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.
Overview of C++ Chapter 2 in both books programs from books keycode for lab: get Program 1 from web test files.
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
Basic Input/Output and Variables Ethan Cerami New York
Introduction. In today’s session… What is programming? Why should I learn programming? Course Outline Introduction to Programming Language Introduction.
Basic Elements of C++ Chapter 2.
FOR DOWNTO Suppose you want to write a FOR-DO loop where the control variable is decreased with each repetition of the loop. Pascal provides the reserved.
Computers and Programming อนันต์ ผลเพิ่ม Anan Phonphoem
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.
Pascal Programming Strings, Arithmetic operators and output formatting National Certificate – Unit 4 Carl Smith.
Copyright 1999 by Larry Fuhrer. Pascal Programming Getting Started...
Lecture #5 Introduction to C++
Pascal language Slides of Omar Al-Nahal. Components of Pascal Language Components of Pascal Language 1. Pascal Character set: - English Letters. - Decimal.
INFORMATION TECHNOLOGY CSEC CXC 10/25/ PASCAL is a programming language named after the 17th century mathematician Blaise Pascal. Pascal provides.
Primitive Variables.
Introduction to Pascal The Basics of Program writing.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 6, Lecture 1 (Monday)
Arithmetic in Pascal A Short Glance We will learn the followings in this chapter Arithmetic operators Order of precedence Assignment statements Arithmetic.
Computer Engineering 1 st Semester Dr. Rabie A. Ramadan 3.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 5, Lecture 1 (Monday)
Programming, an introduction to Pascal
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
1 st semester Basic Pascal Elements อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
1 homework Due today: hw #1 (mailing list printout) readings to date: chapter 1 and chapter read appendix B (3 pages on DOS) and and.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 5P. 1Winter Quarter C Programming Basics Lecture 5.
Pascal Programming Today Chapter 11 1 Chapter 11.
Assignment statement and Arithmetic operation 1 The major part of data processing.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
ISM 2110 Programming for Business Applications Lecture 2 - Section 2 Delphi and Object Pascal Basic By Tony Chun-Kuen WONG Tutorial after 12/09/2002.
Using variable Variables are used to store values.
So now we’re programming What do programs do? Manipulate (process) data Math Read files Write to files Create files.
1 More on Readln:numerical values Note: ENTER key counts sends a carriage return and a line feed to the computer definition: “white space”: space, tab,
1 09/03/04CS150 Introduction to Computer Science 1 What Data Do We Have.
A Simple Program CPSC Pascal Brent M. Dingle Texas A&M University 2001, 2002.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Fall 2001(c)opyright Brent M. Dingle 2001 Abstract Data Types (ADTs) Brent M. Dingle Texas A&M University Chapter 8 – Sections 2 and 3 (and some from Mastering.
Chapter 3 Using Variables, Constants, Formatting Mrs. UlshaferSept
Bill Tucker Austin Community College COSC 1315
Chapter 2 – part b Brent M. Dingle Texas A&M University
Chapter 1.2 Introduction to C++ Programming
Definition of the Programming Language CPRL
A variable is a name for a value stored in memory.
Chapter Topics The Basics of a C++ Program Data Types
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Programming Fundamental
Complex data types Complex data types: a data type made of a complex of smaller pieces. Pascal has four very commonly used complex data types: strings,
Basic Elements of C++.
Data Types, Identifiers, and Expressions
CPSC Pascal Brent M. Dingle Texas A&M University 2001, 2002
CMP 131 Introduction to Computer Programming
Basic Elements of C++ Chapter 2.
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Chapter 2 Variables.
kbkjlj/m/lkiubljj'pl;
Computer Science 1 Get out your notebook
Pascal Subprogram Procedure Function Build in Function (e.g. Sin(x))
Procedures Brent M. Dingle Texas A&M University
CHAPTER FOUR VARIABLES AND CONSTANTS
Variables in C Topics Naming Variables Declaring Variables
Computer Science 1 Get out your notebook
Computer Science 1 Get out your notebook
Сабақтың тақырыбы: Мәлімет типтері. Шамалардың сипатталуы
Presentation transcript:

The CONST definition CONST Pi = 3.14159, City = ‘New York’; Constant identifiers are used when you do not want the value of an identifier to change why not just put the value in the program? Note: The compiler automatically defines the type to the constant identifier by looking at the value assigned to it.

Reserved words Certain words have special meaning to the compiler. Therefore these words cannot be used as constant or variable identifiers. We have seen some examples: DIV, MOD VAR, CONST PROGRAM, BEGIN, END

String Variables Note: This is not part of the Pascal standard. It was added to Turbo Pascal (and some other Pascal compilers) To declare a string variable we could write: VAR Country: string[13]; To assign a value to a string variable we could write: Country := ‘United States’;

More about integers What if you need an integer larger than 32767? Using integer type would be incorrect another type called LongInt is used -2147483648 -> 2147483647 other integer types are: byte (0->255) shortint (-128->127) word (0->65535)

More about reals Reals also have other types real 6 bytes 11 to 12 digits single 4 bytes 7 to 8 digits double 8 bytes 15 to 16 digits extended 10 bytes 19 to 20 digits

Chapter 3 topics write / writeln readln VAR declaration CONST definition assignment statement (including arithmetic)

Homework #3 Problem #1 Write a program that asks the user for his or her age and place of birth. Then write both pieces of information back to the screen in a single WriteLn statement (using a CONST string). Hint: What kind of data type would you want to use for someone's age? What kind of data type would you want to use for a geographic location?

Homework # 3 (con’t) Problem #2 Problem #14 on Page 99 of your text: Write a program to calculate the product of any five real numbers read. What difficulty would the program encounter if it calculated the product of five integers?

Instructions for handing in homework Mail to grader at: fd202@omicron.nyu.edu each program should be included as an attachment The answer to #14, part 2 should be contained in the message body.