Exam1_review - CGS 2425 C+ - Exam 1 Review VARIABLES...

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

View Full Document Right Arrow Icon
CGS 2425 C++ - Exam 1 Review VARIABLES Declaration Type int i = 1; integer float x = 2.5; floating point – 4 bytes double x = 4.25; floating point – 8 bytes char c = ‘A’; single character bool okay = true ; logical boolean (true or false) Variable naming rules : Only letters, numbers, and underscore allowed; Name must not begin with a number. Variables MUST be declared before using them!!!! Always!!! A variable with a non-zero value is equivalent to true . A variable with a value of zero is equivalent to false . CONTROL STRUCTURES Control Structure Example if statement Must begin with an if statement. Can have infinitely many else if statements. Can have at most one else statement, which has no condition. o If no other if statement is entered, the else statement is automatically entered if (x < 0 || y == 5) { // statements } else if (x <= 4 && y != 0) { // statements } else { // statements } do-while statement always executes at least once. do
Background image of page 1

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

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

Page1 / 3

Exam1_review - CGS 2425 C+ - Exam 1 Review VARIABLES...

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