This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Preliminaries Expressions Statements Text File Input/Output C ++ Expressions and Statements Len Blanks CSC 1253 Introduction To Computer Science I Using C ++ Louisiana State University September 22, 2010 Len Blanks C ++ Expressions and Statements Preliminaries Expressions Statements Text File Input/Output Topics 1 Preliminaries 2 Expressions Basic Expressions Basic Numeric Expressions Expressions with SideEffects 3 Statements Declarations Expression Statements Compound Statements Conditional Statements Iterative Statements 4 Text File Input/Output Len Blanks C ++ Expressions and Statements Preliminaries Expressions Statements Text File Input/Output References The material for this lecture is heavily based on content from The C ++ Programming Language by Bjarne Stroustrup. Len Blanks C ++ Expressions and Statements Preliminaries Expressions Statements Text File Input/Output Basic Expressions Basic Numeric Expressions Expressions with SideEffects Expressions All C ++ expressions have a value and a type; some, like assignment, pre and postincrement and decrement and some function references, even have a sideeffect. The simplest valid C ++ expression is formed with a single constant, a single variable, a single array reference, a single function reference (call) or a C ++ expression enclosed in parentheses. More complicated expressions can be formed by combining expressions using operators. Len Blanks C ++ Expressions and Statements Preliminaries Expressions Statements Text File Input/Output Basic Expressions Basic Numeric Expressions Expressions with SideEffects Basic Expressions postincrement lvalue ++ postdecrement lvalue compiletime checked cast static cast< type >( expr ) preincrement ++ lvalue predecrement lvalue logical NOT ! expr unary minus expr unary plus + expr C style cast ( type ) expr multiply expr * expr divide expr / expr modulo expr % expr add expr + expr subtract expr expr Len Blanks C ++ Expressions and Statements Preliminaries Expressions Statements Text File Input/Output Basic Expressions Basic Numeric Expressions Expressions with SideEffects Basic Expressions less than expr < expr less than or equal expr <= expr greater than expr > expr greater than or equal expr >= expr equal expr == expr not equal expr != expr logical AND expr && expr logical OR expr  expr simple assignment lvalue = expr multiply and assign lvalue *= expr divide and assign lvalue /= expr modulo and assign lvalue %= expr add and assign lvalue += expr subtract and assign lvalue= expr Len Blanks C ++ Expressions and Statements Preliminaries Expressions Statements Text File Input/Output Basic Expressions Basic Numeric Expressions Expressions with SideEffects Basic Expressions conditional expression expr ? expr : expr throw exception throw expr comma (sequencing) expression expr , expr Each box holds operators with the same precedence, boxes ordered from highest to lowest precedence. a + b * c means a + (b * c) since * has higher precedence than...
View
Full
Document
This note was uploaded on 10/02/2011 for the course CSC 1253 taught by Professor Staff during the Fall '08 term at LSU.
 Fall '08
 Staff
 Computer Science

Click to edit the document details