# Input and Output! Objectives" (and predefined functions)" 1E3! Topic 4! n Learn what a stream is and examine input and output streams!

Save this PDF as:

Size: px
Start display at page:

Download "Input and Output! Objectives" (and predefined functions)" 1E3! Topic 4! n Learn what a stream is and examine input and output streams!"

## Transcription

1 Input and Output! (and predefined functions)" 1E3! Topic 4! 4 I/O 1 Objectives" n Learn what a stream is and examine input and output streams! n Explore how to read data from the standard input device! n Learn how to write data to the standard output device! n Learn to use predefined functions.! n Discover how to use manipulators in a program to format output 4 I/O 2 1

2 Resources" n This topic is based on Chapter 3 of the textbook.! n You should read Chapter 3 now.! n Skip Putback & Peek; Input Failure; The Clear function; and File Input /Output! n These notes don t cover everything.! 4 I/O 3 What does this pseudocode compute? Input a number-list.! Set x to 0.! FOR EACH number on numberlist! IF number > x! THEN set x to number.! Output x.! A. Sum of numbers B. Max of numbers C. Min of numbers D. None of the above 2

3 n We ve seen! n cin >> n;! Introduction" n Assuming n is declared as an integer, this reads a number from the keyboard and stores it in the variable n.! n cout << The answer is << sum;! n Writes the string in the followed by the value of the variable sum to the screen.! n Here we look more closely at this kind of thing.! 4 I/O 5 Input/Output Streams" n I/O: sequence of bytes (stream of bytes) from source to destination! n Bytes are usually characters, unless program requires other types of information! n Stream: sequence of characters from source to destination! n Input Stream: sequence of characters from an input device to the computer! n Output Stream: sequence of characters from the computer to an output device! 4 I/O 6 3

4 Standard I/O Devices" n Use iostream to extract (receive) data from keyboard and send output to the screen! n iostream contains definitions of two types! n istream - input stream! n ostream - output stream! n iostream has two variables! n cin - stands for common input! n cout - stands for common output! 4 I/O 7 Using cin and cout" n To use cin and cout, the preprocessor directive!#include <iostream> must be used! n The declaration is similar to the following C++ statements:!! istream cin; ostream cout; 4 I/O 8 4

5 cin and the Extraction Operator >>" n The syntax of an input statement using cin and the extraction operator >> is!!!cin >> variable >> variable...; n The extraction operator >> is binary! n The left-hand operand is an input stream variable such as cin n The right-hand operand is a variable of a simple data type! 4 I/O 9 Standard Input" n Every occurrence of >> extracts the next data item from the input stream! n cin >> diam >> price;! n is equivalent to! n cin >> diam; " cin >> price;! n >> skips all whitespace! n Whitespace characters consist of blanks and certain nonprintable characters! 4 I/O 10 5

6 Data Type of Input" n >> distinguishes between character 2 and number 2 by the right hand operand of >> n If it is of type char, the 2 is treated as character 2! n If it is of the type int (or double) the 2 is treated as the number 2 4 I/O 11 Reading Data" n When reading data into a char variable! n Extraction operator >> skips leading whitespace, finds and stores only the next character! n Reading stops after a single character! 4 I/O 12 6

7 Reading Data (Continued)" n To read data into an int or double variable! n Extraction operator >> skips leading whitespace, reads plus or minus sign (if any), reads the digits (including decimal)! n Reading stops on whitespace non-digit character! n Study example 3.1 in the text.! 4 I/O 13 Using Predefined Functions" n A function (subprogram): set of instructions! n When activated, it accomplishes a task! n main executes when a program is run! n Other functions execute only when called! n C++ includes a wealth of functions! n Predefined functions are organized as a collection of libraries called header files! 4 I/O 14 7

8 Predefined Functions" n Header file may contain several functions! n To use a predefined function, you need the name of the appropriate header file! n You also need to know:! n Function name! n Number of parameters required! n Type of each parameter! n What the function is going to do! 4 I/O 15 Predefined Function Example" n To compute x y use pow (power) function.! n pow is in the cmath library! n As are sqrt, sin, cos, log, log10, n pow takes two numeric parameters! n pow returns a number.! n E.g. x = pow(2,3);"!cout << pow (x, 3);! 4 I/O 16 8

9 Use the cmath library Example continued" n The output of the previous program is! 2 to the power of 6 = to the power of 3 = u = 64 The example shows how to call a function, pass parameters to it and use the value that it returns (if it returns one).! 4 I/O 18 9

10 cin and the get Function" n >> can t be used to read blanks or to notice new lines.! n because >> skips blanks and newlines.! n The get function! n Inputs next character (including whitespace)! n Stores character at location indicated by its argument! n The syntax of cin and the get function:! " cin.get(varchar);! 4 I/O 19 Example" n Suppose I want to read two characters, either of which may be a blank, followed by an integer:! cin.get(ch1);! cin.get(ch2);! cin >> num;! n If I type A 34,! n ch1 will be A, ch2 will be and num will be 34.! 4 I/O 20 10

11 Other istream functions" n Note the sections on ignore, putback and peek for future reference.! n These are functions which allow greater control over the input stream.! n For example! n cin.ignore (100,. ); n Skips up to 100 characters until a full stop is read. The. would be discarded too. 4 I/O 21 Input Failure" n Things can go wrong during execution! n If input data does not match the corresponding variables, the program may run into problems! n Trying to read a letter into an int or double variable would result in an input failure! n If an error occurs when reading data! n Input stream enters the fail state! 4 I/O 22 11

12 Input Failure (continued)" n Once in a fail state, all further I/O statements using that stream are ignored! n The program continues to execute with whatever values are stored in variables! n This causes incorrect results! n The clear function restores input stream to a working state!!!istreamvar.clear(); 4 I/O 23 Output" n The syntax of cout and << is:!!cout<< expression or manipulator << expression or manipulator <<...; n Called an output (cout) statement! n The << operator is called the insertion operator or the stream insertion operator! n Expression evaluated and its value is printed at the current cursor position on the screen! 12

13 Output (continued)" n Manipulator: alters output! n endl: the simplest manipulator! n Causes cursor to move to beginning of the next line! n cout << u << endl << name;! n where u=2034 and name is Mary would produce!!2034 Mary! The New Line Character" n Another way of moving to a new line is to include \n in an output string.! n \n is the new line character. n Tells the output to go to the next line! n cout << Line 1\nLine 2\n << name;" n where name is Mary would produce " n Line 1 Line 2 Mary" 13

14 Formatting Output" n As well as the endl manipulator! n setprecision(n) outputs decimal numbers with up to n decimal places! n fixed outputs floating-point numbers in a fixed decimal format! n showpoint forces output to show the decimal point and trailing zeros! 4 I/O 28 14

15 The setw Manipulator" n setw outputs the value of an expression in specific columns! n If the number of columns exceeds the number of columns required by the expression! n Output of the expression is right-justified! n Unused columns to the left are filled with spaces! 4 I/O 29 Types of Manipulators" n Two types of manipulators:! n With parameters! n Without parameters! n Parameterized: require iomanip header! n setprecision, setw, and setfill n Nonparameterized: require iostream header! n endl, fixed, showpoint, left, and flush 4 I/O 30 15

16 I/O and the string Type" n An input stream variable (cin) and extraction operator >> can read a string into a variable of the data type string! n Extraction operator! n Skips any leading whitespace characters and reading stops at a whitespace character! n Can not be used to read strings with blanks! n The function getline n Reads until end of the current line! n Should be used to read strings with blanks! 4 I/O 31 Highlights" q cin and cout are the common input and output streams.! n >> extracts data from an input stream into a variable.! n << pushes data to an output stream! n get and getline allow finer level control! n iomanip library provides manipulators for formatting output.! 4 I/O 32 16

### C++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 3: Input/Output

C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 3: Input/Output Objectives In this chapter, you will: Learn what a stream is and examine input and output streams Explore

### C++ Input/Output: Streams

C++ Input/Output: Streams 1 The basic data type for I/O in C++ is the stream. C++ incorporates a complex hierarchy of stream types. The most basic stream types are the standard input/output streams: istream

### Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language

Simple C++ Programs Engineering Problem Solving with C++, Etter/Ingber Chapter 2 Simple C++ Programs Program Structure Constants and Variables C++ Operators Standard Input and Output Basic Functions from

### CS101: Fundamentals of Computer Programming. Dr. Tejada www-bcf.usc.edu/~stejada Week 4: Arrays,Strings, File I/O

CS101: Fundamentals of Computer Programming Dr. Tejada stejada@usc.edu www-bcf.usc.edu/~stejada Week 4: Arrays,Strings, File I/O 2 Problem: Write a program to calculate the average test score for 10 students

### Adjusted/Modified by Nicole Tobias. Chapter 2: Basic Elements of C++

Adjusted/Modified by Nicole Tobias Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types

### Basics of I/O Streams and File I/O

Basics of This is like a cheat sheet for file I/O in C++. It summarizes the steps you must take to do basic I/O to and from files, with only a tiny bit of explanation. It is not a replacement for reading

### Module I Basic elements in C++

Module I Basic elements in C++ Objectives In this topic, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates arithmetic

### 6.1. Introduction to Void Functions (Procedures) L E S S O N S E PURPOSE PROCEDURE

L E S S O N S E 6.1 T Introduction to Void Functions (Procedures) PURPOSE PROCEDURE 1. To introduce the concept of void functions (procedures) 2. To work with void functions (procedures) that have no parameters

### Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to

### Sequential Program Execution

Sequential Program Execution Quick Start Compile step once always g++ -o Realtor1 Realtor1.cpp mkdir labs cd labs Execute step mkdir 1 Realtor1 cd 1 cp../0/realtor.cpp Realtor1.cpp Submit step cp /samples/csc/155/labs/1/*.

### Engineering Problem Solving with C++, Etter

Engineering Problem Solving with C++, Etter Chapter 7 Strings 12-11-13 1 Strings Character Strings The string Class. 2 C style strings functions defined in cstring CHARACTER STRINGS 3 C Style Character

### Programming Fundamental. Instructor Name: Lecture-2

Programming Fundamental Instructor Name: Lecture-2 Today s Lecture What is Programming? First C++ Program Programming Errors Variables in C++ Primitive Data Types in C++ Operators in C++ Operators Precedence

### Chapter 4 Intro to Programming in C++

Chapter 4 Intro to Programming in C++ 4-1 Computer Programming Earlier we defined an algorithm to be a step by step process for solving a problem. Computer programming is the process of implementing the

### Member Functions of the istream Class

Member Functions of the istream Class The extraction operator is of limited use because it always uses whitespace to delimit its reads of the input stream. It cannot be used to read those whitespace characters,

### Chapter 2: Elements of Java

Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction

### PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members

### Formatting Numbers with C++ Output Streams

Formatting Numbers with C++ Output Streams David Kieras, EECS Dept., Univ. of Michigan Revised for EECS 381, Winter 2004. Using the output operator with C++ streams is generally easy as pie, with the only

### C++ String Variables. 12. C++ Strings. The standard C++ library provides an object string type to complement the string literals used earlier:

C++ String Variables 1 The standard C++ library provides an object string type to complement the string literals used earlier: string Name1, Name2; // must #include A string variable may be assigned

### Introduction to C++ Programming

2 Introduction to C++ Programming OBJECTIVES In this chapter you will learn: To write simple computer programs in C++. To write simple input and output statements. To use fundamental types. Basic computer

### Each statement is ended by a semi-colon (;). The formatting is free.

Example 1 cout x; double err, tol=1e-12, x1; int it, maxit=100; it = 0; err = tol + 1; while( err > tol && it < maxit ) x1 = x - (x-cos(x))/(1+sin(x)); err = fabs(

### Chapter One Introduction to Programming

Chapter One Introduction to Programming 1-1 Algorithm and Flowchart Algorithm is a step-by-step procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of

### C++ Language Tutorial

cplusplus.com C++ Language Tutorial Written by: Juan Soulié Last revision: June, 2007 Available online at: http://www.cplusplus.com/doc/tutorial/ The online version is constantly revised and may contain

### Introduction to C++ Programming

cpphtp5_02.fm Page 36 Wednesday, December 15, 2004 11:11 AM 2 Introduction to C++ Programming OBJECTIVES In this chapter you will learn: To write simple computer programs in C++. To write simple input

### C Syntax and Semantics

C Syntax and Semantics 1 C Program Structure C Language Elements Preprocessor directives Function Header, and Function body Executable statements Reserved word, Standard identifiers, user defined identifiers

### 7.7 Case Study: Calculating Depreciation

7.7 Case Study: Calculating Depreciation 1 7.7 Case Study: Calculating Depreciation PROBLEM Depreciation is a decrease in the value over time of some asset due to wear and tear, decay, declining price,

### Function Definitions

Functions 8 22 absdiff 14 1. Perspective is messed up here. 2. Picture needs to be redone in truespace. 3. Think of a function as a black box (meaning you shouldn't worry about what is happening inside)

### KENDRIYA VIDYALAYA TIRUMALAGIRI HOLIDAY HOMEWORK CLASS XII COMPUTER SCIENCE (083) C++ Practice Problems

(i).there are 39 problems. KENDRIYA VIDYALAYA TIRUMALAGIRI HOLIDAY HOMEWORK CLASS XII COMPUTER SCIENCE (083) C++ Practice Problems 1. What is the exact output of the program below? Indicate a blank space

### The little endl that couldn t

This is a pre-publication draft of the column I wrote for the November- December 1995 issue of the C++ Report. Pre-publication means this is what I sent to the Report, but it may not be exactly the same

### Passing 1D arrays to functions.

Passing 1D arrays to functions. In C++ arrays can only be reference parameters. It is not possible to pass an array by value. Therefore, the ampersand (&) is omitted. What is actually passed to the function,

### Answers to Review Questions Chapter 7

Answers to Review Questions Chapter 7 1. The size declarator is used in a definition of an array to indicate the number of elements the array will have. A subscript is used to access a specific element

### UEE1302 (1102) F10 Introduction to Computers and Programming (I)

Computational Intelligence on Automation Lab @ NCTU UEE1302 (1102) F10 Introduction to Computers and Programming (I) Programming Lecture 08 Strings: C-String, Character Manipulation and Class string Learning

### OBJECT ORIENTED PROGRAMMING IN C++

OBJECT ORIENTED PROGRAMMING IN C++ For Off Campus BSc Computer Science Programme UNIT 1 1. The goal of programmers is to develop software that are. A. Correct B. Reliable and maintainable C. Satisfy all

### Lecture 1 Notes: Introduction

Introduction to C++ January 4, 2011 Massachusetts Institute of Technology 6.096 Lecture 1 Notes: Introduction 1 Compiled Languages and C++ 1.1 Why Use a Language Like C++? At its core, a computer is just

### QUIZ-II QUIZ-II. Chapter 5: Control Structures II (Repetition) Objectives. Objectives (cont d.) 20/11/2015. EEE 117 Computer Programming Fall-2015 1

QUIZ-II Write a program that mimics a calculator. The program should take as input two integers and the operation to be performed. It should then output the numbers, the operator, and the result. (For

### Computers process data under the control of sets of instructions called computer programs.

Introduction Computer is a device capable of performing computations and making logical decisions at speeds millions and even billions of times faster than human beings. Computers process data under the

### What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be...

What is a Loop? CSC Intermediate Programming Looping A loop is a repetition control structure It causes a single statement or a group of statements to be executed repeatedly It uses a condition to control

### The C++ Language. Loops. ! Recall that a loop is another of the four basic programming language structures

The C++ Language Loops Loops! Recall that a loop is another of the four basic programming language structures Repeat statements until some condition is false. Condition False True Statement1 2 1 Loops

### C Programming Dr. Hasan Demirel

C How to Program, H. M. Deitel and P. J. Deitel, Prentice Hall, 5 th edition (3 rd edition or above is also OK). Introduction to C Programming Dr. Hasan Demirel Programming Languages There are three types

### Ubuntu. Ubuntu. C++ Overview. Ubuntu. History of C++ Major Features of C++

Ubuntu You will develop your course projects in C++ under Ubuntu Linux. If your home computer or laptop is running under Windows, an easy and painless way of installing Ubuntu is Wubi: http://www.ubuntu.com/download/desktop/windowsinstaller

### Python to C/C++ Fall 2011

Python to C/C++ Fall 2011 1. Main Program Python: Program code is indented after colon : def main(): body of program C/C++: Have more setup overhead. C: Both require #include directives to access libraries

### PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON

PROBLEM SOLVING WITH SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON Addison Wesley Boston San Francisco New York London

### Scanner. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit.

Scanner The Scanner class is intended to be used for input. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit. For example, suppose the input

### Lecture 3. Arrays. Name of array. c[0] c[1] c[2] c[3] c[4] c[5] c[6] c[7] c[8] c[9] c[10] c[11] Position number of the element within array c

Lecture 3 Data structures arrays structs C strings: array of chars Arrays as parameters to functions Multiple subscripted arrays Structs as parameters to functions Default arguments Inline functions Redirection

### PRINT USING Procedures

-1 CHAPTER PRINT USING Procedures True BASIC normally prints numbers in a form convenient for most purposes. But on occasion you may prefer a more elaborate form. For eample, you may want to print financial

### Introduction to Python

Caltech/LEAD Summer 2012 Computer Science Lecture 2: July 10, 2012 Introduction to Python The Python shell Outline Python as a calculator Arithmetic expressions Operator precedence Variables and assignment

### Multichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is

Multichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is preceded by an equal sign d. its name has undereline 2. Associations

DalePhatANS_complete 8/18/04 10:30 AM Page 1049 Answers to Selected Exercises Chapter 1 Exam Preparation Exercises 1. a. v, b. i, c. viii, d. iii, e. iv, f. vii, g. vi, h. ii. 2. Analysis and specification,

### Computer Programming C++ Classes and Objects 15 th Lecture

Computer Programming C++ Classes and Objects 15 th Lecture 엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University Copyrights 2013 Eom, Hyeonsang All Rights Reserved Outline

### Repetition and Loops. Additional Python constructs that allow us to effect the (1) order and (2) number of times that program statements are executed.

New Topic Repetition and Loops Additional Python constructs that allow us to effect the (1) order and (2) number of times that program statements are executed. These constructs are the 1. while loop and

### So far we have considered only numeric processing, i.e. processing of numeric data represented

Chapter 4 Processing Character Data So far we have considered only numeric processing, i.e. processing of numeric data represented as integer and oating point types. Humans also use computers to manipulate

### Engineering Problem Solving with C++, Etter/Ingber

Engineering Problem Solving with C++, Etter/Ingber Chapter 3 Control Structures 1 Control structures Algorithm Development Conditional Expressions Selection Statements Repetition Statements Structuring

### Selection: if Statement

: if Statement The simplest selection structure in C++ is the if statement. Syntactically: 1 if The Boolean expression must be enclosed in parentheses, and

### J a v a Quiz (Unit 3, Test 0 Practice)

Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points

### Part IA Computing Course Tutorial Guide to C++ Programming

Part IA Computing Course Tutorial Guide to C++ Programming Roberto Cipolla Department of Engineering University of Cambridge September 1, 2004 This document provides an introduction to computing and the

### Stacks. Linear data structures

Stacks Linear data structures Collection of components that can be arranged as a straight line Data structure grows or shrinks as we add or remove objects ADTs provide an abstract layer for various operations

### Standard printing function in C is printf Prints everything numbers, strings, etc. May be complex to use. Standard C library is called libc

Arrays and Structs and Pointers, Oh My! Programming in C Input and output Using printf Standard input and output Pointers Arrays Structures Combining these things together Arrays and Structs and Pointers,

### Object-Oriented Programming. Lecture 8 Dr Piotr Cybula

Object-Oriented Programming Lecture 8 Dr Piotr Cybula Standard Template Library (STL) input/output streams: iostream, fstream, sstream, iomanip string management: string standard

### Introduction to Programming

Introduction to Programming SS 2012 Adrian Kacso, Univ. Siegen adriana.dkacsoa@duni-siegena.de Tel.: 0271/740-3966, Office: H-B 8406 Stand: April 25, 2012 Betriebssysteme / verteilte Systeme Introduction

### TI-83 Plus Graphing Calculator Keystroke Guide

TI-83 Plus Graphing Calculator Keystroke Guide In your textbook you will notice that on some pages a key-shaped icon appears next to a brief description of a feature on your graphing calculator. In this

### Common Syntax and Semantic Errors

C H A P T E R 2 Common Syntax and Semantic Errors 2.1 CHAPTER OBJECTIVES To understand the fundamental characteristics of syntax and semantic errors To be able to identify specific common syntax and semantic

### 1 Description of The Simpletron

Simulating The Simpletron Computer 50 points 1 Description of The Simpletron In this assignment you will write a program to simulate a fictional computer that we will call the Simpletron. As its name implies

### Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating

### Boolean Logic. Boolean Expressions. What and means. And, Or, Not, True, False. What not means. What or means. Truths and Falsehoods

Boolean Logic Boolean Expressions Truths and Falsehoods Boolean logic (algebra) is named after George Boole He wrote the book Investigation of the Laws of Thought in 1854 Also called propositional logic

### Introduction to Programming (in C++) Loops. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC

Introduction to Programming (in C++) Loops Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC Example Assume the following specification: Input: read a number N > 0 Output:

### Example. Introduction to Programming (in C++) Loops. The while statement. Write the numbers 1 N. Assume the following specification:

Example Introduction to Programming (in C++) Loops Assume the following specification: Input: read a number N > 0 Output: write the sequence 1 2 3 N (one number per line) Jordi Cortadella, Ricard Gavaldà,

### The Basics of C Programming. Marshall Brain

The Basics of C Programming Marshall Brain Last updated: October 30, 2013 Contents 1 C programming 1 What is C?................................. 2 The simplest C program, I........................ 2 Spacing

### Basic Formulas in Excel. Why use cell names in formulas instead of actual numbers?

Understanding formulas Basic Formulas in Excel Formulas are placed into cells whenever you want Excel to add, subtract, multiply, divide or do other mathematical calculations. The formula should be placed

### Chapter 5 Functions. Introducing Functions

Chapter 5 Functions 1 Introducing Functions A function is a collection of statements that are grouped together to perform an operation Define a function Invoke a funciton return value type method name

### Some Scanner Class Methods

Keyboard Input Scanner, Documentation, Style Java 5.0 has reasonable facilities for handling keyboard input. These facilities are provided by the Scanner class in the java.util package. A package is a

### Lecture 4 Notes: Arrays and Strings

6.096 Introduction to C++ January 10, 2011 Massachusetts Institute of Technology John Marrero Lecture 4 Notes: Arrays and Strings 1 Arrays So far we have used variables to store values in memory for later

A Summary of Operator Overloading David Kieras, EECS Dept., Univ. of Michigan Prepared for EECS 381 8/27/2013 Basic Idea You overload an operator in C++ by defining a function for the operator. Every operator

### Numeral Systems. The number twenty-five can be represented in many ways: Decimal system (base 10): 25 Roman numerals:

Numeral Systems Which number is larger? 25 8 We need to distinguish between numbers and the symbols that represent them, called numerals. The number 25 is larger than 8, but the numeral 8 above is larger

### Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:

Introduction to Programming and Algorithms Module 2 CS 146 Sam Houston State University Dr. Tim McGuire Introduction To Computers And Java Chapter Objectives To understand: the meaning and placement of

### Appendix M Introduction to Microsoft Visual C++.NET

Appendix M Introduction to Microsoft Visual C++.NET This appendix serves as a quick reference for performing the following operations using the Microsoft Visual C++.NET integrated development environment

### An Incomplete C++ Primer. University of Wyoming MA 5310

An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages

### C++ INTERVIEW QUESTIONS

C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get

1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays

### Lecture 03 Bits, Bytes and Data Types

Lecture 03 Bits, Bytes and Data Types In this lecture Computer Languages Assembly Language The compiler Operating system Data and program instructions Bits, Bytes and Data Types ASCII table Data Types

### CSCI 123 Introduction to Programming Concepts in C++

CSCI 123 Introduction to Programming Concepts in C++ Brad Rippe Functions Top Down Design Applications Top-Down Design Browser Program Top Down Design Browser User Interface Thread Pool Cache Manager Update

### ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters

The char Type ASCII Encoding The C char type stores small integers. It is usually 8 bits. char variables guaranteed to be able to hold integers 0.. +127. char variables mostly used to store characters

### Scripting with TCL, Part 1

Scripting with TCL, Part 1 Axel Kohlmeyer Center for Molecular Modeling University of Pennsylvania SBS 2007 @ JNCASR, Bangalore The VMD Execution Model GUI (FLTK) Internal State Visualization Python Interpreter

### Programming Languages CIS 443

Course Objectives Programming Languages CIS 443 0.1 Lexical analysis Syntax Semantics Functional programming Variable lifetime and scoping Parameter passing Object-oriented programming Continuations Exception

### The Payroll Program. Payroll

The Program 1 The following example is a simple payroll program that illustrates most of the core elements of the C++ language covered in sections 3 through 6 of the course notes. During the term, a formal

### IN THIS CHAPTER,YOU ARE INTRODUCED to the C language so that you can see what

3 Compiling and Running Your First Program IN THIS CHAPTER,YOU ARE INTRODUCED to the C language so that you can see what programming in C is all about.what better way to gain an appreciation for this language

### El Dorado Union High School District Educational Services

El Dorado Union High School District Course of Study Information Page Course Title: ACE Computer Programming II (#495) Rationale: A continuum of courses, including advanced classes in technology is needed.

### While Loop. 6. Iteration

While Loop 1 Loop - a control structure that causes a set of statements to be executed repeatedly, (reiterated). While statement - most versatile type of loop in C++ false while boolean expression true

### Lecture 5: Java Fundamentals III

Lecture 5: Java Fundamentals III School of Science and Technology The University of New England Trimester 2 2015 Lecture 5: Java Fundamentals III - Operators Reading: Finish reading Chapter 2 of the 2nd

### Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 04 Digital Logic II May, I before starting the today s lecture

### TI-86 Graphing Calculator Keystroke Guide

TI-86 Graphing Calculator Keystroke Guide In your textbook you will notice that on some pages a key-shaped icon appears next to a brief description of a feature on your graphing calculator. In this guide

### sqlite driver manual

sqlite driver manual A libdbi driver using the SQLite embedded database engine Markus Hoenicka mhoenicka@users.sourceforge.net sqlite driver manual: A libdbi driver using the SQLite embedded database engine

### Python 3.3 to C/C++ Summer 2014

Python 3.3 to C/C++ Summer 2014 1. Main Program Python: Program code is indented after colon : def main(): body of program C/C++: Have more setup overhead. Both require #include directives to access libraries

### CSCI 123 Introduction to Programming Concepts in C++

CSCI 123 Introduction to Programming Concepts in C++ Brad Rippe String and Vectors Overview 8.1 An Array Type for Strings 8.2 The Standard string Class 8.3 Vectors 8.1 An Array Type for Strings An Array

### Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

### 2 Programs: Instructions in the Computer

2 2 Programs: Instructions in the Computer Figure 2. illustrates the first few processing steps taken as a simple CPU executes a program. The CPU for this example is assumed to have a program counter (PC),

### Sources: On the Web: Slides will be available on:

C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

### MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java

### Oracle Database: SQL and PL/SQL Fundamentals

Oracle University Contact Us: +966 12 739 894 Oracle Database: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training is designed to