Engineering Science 1036A/B Lecture Notes - Lecture 5: Standard Streams, Backslash

16 views4 pages
Input: cin
istream object
Inputs any non-whitespace data from the standard input (console/keyboard) on
to a declared variable
Stands for console input
General form: cin >> var1>>var2;
Uses the >> (input) operator which can extract any non-whitespace data from
the standard input
>> is known as the data extraction operator
Never use endl within cin statement
First value entered form the keyboard will be assigned to var1 while the
second one will be assigned to var2
cout statement precedes cin statement to prompt user to enter data
Output: cout
ostream object
Displays a message and/or data to the standard output (console or monitor)
stands for console output
General form: cout <<expression <<expression;
An expression can be:
String constant: one or more characters enclosed by "
§
Character constant: single character enclosed by '
§
Identifier: variable name
§
Formula: arithmetic and/or logical expressions
§
Function call
§
<< operator : stream insertion operator
Sends a processed stream to a console
Backslash Codes with cout
Aka "escape sequence"
Need to be used as string constants
Enclosed in a pair of double quotation marks
Standard Input/output
Unlock document

This preview shows page 1 of the document.
Unlock all 4 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents