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,

Slides:



Advertisements
Similar presentations
C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
Advertisements

What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
CPS120: Introduction to Computer Science INPUT/OUTPUT.
Programming In C++ Spring Semester 2013 Lecture 2 Programming In C++, Lecture 2.
Arrays Liang, Chpt 5. arrays Fintan Array of chars For example, a String variable contains an array of characters: An array is a data structure.
J. Michael Moore Input and Output (IO) CSCE 110 Drawn from James Tam's material.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
1 Key Concepts:  Data types in C.  What is a variable?  Variable Declaration  Variable Initialization  Printf()  Scanf()  Working with numbers in.
Input and Output (IO) CSCE 110 Drawn from James Tam's material.
Guide To UNIX Using Linux Third Edition
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 11, Lecture 2 (Wed)
1 - buttons Click “Step Forward” to execute one line of the program. Click “Reset” to start over. “Play,” “Stop,” and “Step Back” are disabled in this.
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
Fortran 1- Basics Chapters 1-2 in your Fortran book.
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.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Procedures and Functions Computing Module 1. What is modular programming? Most programs written for companies will have thousands of lines of code. Most.
Console Input & Output CSS 161: Fundamentals of Computing Joe McCarthy 1.
Input, Output, and Processing
Copyright 1999 by Larry Fuhrer. Pascal Programming Getting Started...
C Programming Lecture 10 Instructor: Wen, Chih-Yu Department of Electrical Engineering National Chung Hsing University.
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
INFORMATION TECHNOLOGY CSEC CXC 10/25/ PASCAL is a programming language named after the 17th century mathematician Blaise Pascal. Pascal provides.
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
Pascal Programming Files and Text (an intro). Pascal Programming Files... Data files need to be retained in secondary memory. The machine memory is random.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 5, Lecture 1 (Monday)
1 st semester Basic Pascal Elements อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
Pointers A pointer is a variable that contains a memory address as it’s value. The memory address points to the actual data. –A pointer is an indirect.
1 Program Input Software Design Chapter 4. 2 You Will Want to Know... Prompting for and reading values into a program. Accessing data from a file. What.
Pascal Programming Today Chapter 11 1 Chapter 11.
1 STRINGS String data type Basic operations on strings String functions String procedures.
Chapter 2 Input, Variables and Data Types. JAVA Input JAVA input is not straightforward and is different depending on the JAVA environment that you are.
24-2 Perform File I/O using file pointers FILE * data-type Opening and closing files Character Input and Output String Input and Output Related Chapter:
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
1 CSC103: Introduction to Computer and Programming Lecture No 24.
So now we’re programming What do programs do? Manipulate (process) data Math Read files Write to files Create files.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 5, Lecture 2 (Tuesday)
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
C++ Programming Lecture 14 Arrays – Part I The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Declaring fstream Objects An istream object named cin connects program and keyboard An ostream object named cout connects the program and the screen These.
CS162 External Data Files 1 Today in CS162 External Files What is an external file? How do we save data in a file?
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
Slides prepared by Rose Williams, Binghamton University Console Input and Output.
A Simple Program CPSC Pascal Brent M. Dingle Texas A&M University 2001, 2002.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
1 Stream Input and Output Read Text, page Keyboard and Screen I/O #include cin (of type istream) cout (of type ostream) KeyboardScreen executing.
CCSA 221 Programming in C INPUT AND OUTPUT OPERATIONS IN C – PART 1 1.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Buffer Whenever a read or readln is executed and you type a line of data terminated by hitting ENTER, that line, along with the CR/LF end of line marker.
Chapter 6 JavaScript: Introduction to Scripting
What Actions Do We Have Part 1
Chapter 2 Introduction to C++ Programming
The CONST definition CONST Pi = , City = ‘New York’;
CPS120: Introduction to Computer Science
Revision Lecture
Introduction to C++.
getline() function with companion ignore()
Introduction to C++ Programming
More Loops.
Basic Input and Output C++ programs can read and write information using streams A simple input stream accepts typed data from a keyboard A simple output.
Introduction to C++ Programming
An Introduction to Programming with C++ Fifth Edition
Using string type variables
getline() function with companion ignore()
Presentation transcript:

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, carriage return, line feed white space is used to delimit integers and reals

2 Read vs. Readln Readln is like Writeln: After the command is complete, the program’s “input or output pointer” moves to the next line –Writeln: next output placed on the next line –Readln: next input comes from the next line (this means the rest of the input on the original line will be ignored)

3 Read vs. Readln (con’t) Read is like Write: After the command is complete, the program’s “input or output pointer” stays on the same line –Write: next output placed immediately to the right of previous output –Read: next input comes from the next (on the right) character that was entered by user (note: input is not always entered by a user)

4 Reading Characters No delimiters can be used because white space characters are valid characters ENTER key is read as two characters: –carriage return –line feed

5 We will skip section 4.6

6 Reading Strings Use readln for strings - NEVER use read readln reads the whole line except CR/LF If the number of characters in the string is less than the length of the string variable, the entire string is assigned to the variable. If the number of characters in the string is more than the length of the string variable, the computer will assign as many characters as can fit in the variable beginning with the first character

7 Reading strings and numbers together If you need to read both strings and numbers in the same line, you should read the numbers first.

8 Buffer definitions Whenever a read or readln is executed and you type a line of data terminated by hitting ENTER, that line, along with the CR/LF end of line marker is stored as characters in a series of memory locations called the input buffer. –Remember CR and LF are stored as two separate characters

9 Pointer While data is in the buffer, the program keeps track of the location it will read the next data item from. After read is used to read data, the pointer points to the character immediately to the right of the last character used. Readln sets the pointer to the first character in the next line.

10 Using Units Unit: A group of compiled procedures, along with the definitions and declarations they use. Standard Units: Predefined units that come with the Turbo Pascal compiler

11 Standard Units Crt: screen and keyboard procedures DOS: allows use of DOS commands in program System: (automatically included) standard functions and procedure Printer: printer functions and procedures Overlay, Graph: we will not use