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

Slides:



Advertisements
Similar presentations
Chapter 3. Expressions and Interactivity CSC125 Introduction to C++
Advertisements

L2:CSC © Dr. Basheer M. Nasef Lecture #2 By Dr. Basheer M. Nasef.
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.
Data types and variables
 2007 Pearson Education, Inc. All rights reserved C Formatted Input/Output.
CS150 Introduction to Computer Science 1
Chapter 2: Introduction to C++.
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
Basic Elements of C++ Chapter 2.
Data Types. Every program must deal with data The data is usually described as a certain type This type determines what you can do with the data and how.
Chapter 2 Data Types, Declarations, and Displays.
Objectives You should be able to describe: Data Types
CSC 125 Introduction to C++ Programming Chapter 2 Introduction to C++
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Streams Streams –Sequences of characters organized.
Chapter 9 Formatted Input/Output. Objectives In this chapter, you will learn: –To understand input and output streams. –To be able to use all print formatting.
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.
Fortran 1- Basics Chapters 1-2 in your Fortran book.
Input & Output: Console
Copyright 2006 Addison-Wesley Brief Version of Starting Out with C++ Chapter 2 Introduction to C++
Pascal Programming Strings, Arithmetic operators and output formatting National Certificate – Unit 4 Carl Smith.
Copyright 1999 by Larry Fuhrer. Pascal Programming Getting Started...
CPS120: Introduction to Computer Science
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
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.
C++ Programming: Basic Elements of C++.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Introduction to Pascal The Basics of Program writing.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 6, Lecture 1 (Monday)
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
Computer Engineering 1 st Semester Dr. Rabie A. Ramadan 3.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 5, Lecture 1 (Monday)
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.
Chapter 3 – Variables and Arithmetic Operations. Variable Rules u Must declare all variable names –List name and type u Keep length to 31 characters –Older.
Programming with Visual C++: Concepts and Projects Chapter 3A: Integral Data (Concepts)
Pascal Programming Today Chapter 11 1 Chapter 11.
C++ Basics Tutorial 5 Constants. Topics Covered Literal Constants Defined Constants Declared Constants.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
CPS120: Introduction to Computer Science Variables and Constants.
Chapter One Lesson Three DATA TYPES ©
Murach, Chapter 4. Two Data Types Value Types – Store their own data Reference Types Do not store their own data Stores a reference to an area of memory.
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,
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 5, Lecture 2 (Tuesday)
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
+ Note On the Use of Different Data Types Use the data type that conserves memory and still accomplishes the desired purpose. For example, depending on.
Pascal Programming Today Chapter 2 1 Chapter 2. Pascal Programming Today Chapter 2 2 »Output statements write data to output devices (e.g. VDU). »Two.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Chapter 3 Using Variables, Constants, Formatting Mrs. UlshaferSept
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
Definition of the Programming Language CPRL
Data Types, Variables & Arithmetic
Programming Fundamentals
The CONST definition CONST Pi = , City = ‘New York’;
Wel come.
TMF1414 Introduction to Programming
CPSC Pascal Brent M. Dingle Texas A&M University 2001, 2002
CMP 131 Introduction to Computer Programming
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.
kbkjlj/m/lkiubljj'pl;
Chapter 2: Introduction to C++.
The Data Element.
Primitive Types and Expressions
The Data Element.
Variables and Constants
Presentation transcript:

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

2 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

3 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’;

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

5 More about reals Reals also have other types –real6 bytes11 to 12 digits –single4 bytes7 to 8 digits –double8 bytes15 to 16 digits –extended10 bytes19 to 20 digits

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

7 Formatting output: integers Field: a group of columns in which results are printed is called a field Field width: The number of columns in the field writeln(IntId:##) –IntId is an integer identifier or value –## is the rightmost column to print the integer (Compiler will ignore this value if its smaller than number of digits) can be written as any integer expression default is one

8 Formatting output: reals Writeln (RealId:#1:#2) –RealId is a real identifier or value –#1 is the rightmost column to print the real –#2 is the number of digits you want on the right of the decimal point. If #2 is omitted, scientific notation is used

9 Formatting output: strings Writeln (stringId:##) –stringId can be a string or character identifier or value –## is the rightmost column for the string to be printed in

10 Formatting output: Boolean Similar to strings note: Although the compiler is not Cap sensitive, it always prints Boolean values in all CAPS.