summary02 - ie: C++ is equivalent to C = C + 1 Chapter 2.5...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
if (Boolean_Expression) Yes_Statement else No_Statement Summary Ch 2.3 – 2.5, 11.2 Chapter 2.3 Data Types and Expressions Major Types Int ( 2 ) Double ( 2.00 ) Char ( a ) Bool ( false ) Operators Addition (+) Subtraction (-) Multiplication (*) Division (/) Division with remainder (%) Chapter 2.4 Simple Flow of Control The if statement tests an expression and executes a statement only if the expression is true If the expression is false, the else statement executes the no statement Can be used to connect expressions && - And || - Or Example: If (y < 0) || (y > 12) Can have an if statement without a connected else Do not use: if (z < x < y) – instead use Assignment statement = Is equal to- == can use a while loop to repeat statements within { } use increment and decrement operators to add or subtract one to a value
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ie: C++ is equivalent to C = C + 1 Chapter 2.5 Program Style • Indentations and proper line spacing are key to a readable program • //------------------- or /* ---------------------------------- */ are comments. • Do not comment the obvious • Use file name, author of program, how to contact, assignment number, last modified • Important to declare variables for easier changes, avoid confusion • Constants prevent values from changing Chapter 11.2 The Standard string Class • C strings arrays of characters terminated with \ , very inefficient for programming. • #include <string> • use getline(cin, line) to input a whole line • Can use a character (?) as stopping point by using getline(cin, line, ‘?’); • Name.length(); number of characters...
View Full Document

This note was uploaded on 08/26/2009 for the course CS 140 taught by Professor Staff during the Fall '08 term at Southern Illinois University Edwardsville.

Page1 / 2

summary02 - ie: C++ is equivalent to C = C + 1 Chapter 2.5...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online