2. C++ basics (updates)

2. C++ basics (updates) - Constants Constants are...

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

View Full Document Right Arrow Icon
Constants Constants are expressions with a fixed value Literals are notations for representing a fixed value in the source code Literal constants in C++ Integer numerals Floating point numbers Character constants String literals Boolean literals 10
Background image of page 1

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

View Full DocumentRight Arrow Icon
Integer Numerals Represent integer decimal values Can be expressed using decimal numbers (base 10) octal numbers (base 8) precede with a 0 hexadecimal numbers (base 16) precede with the characters 0x Examples: 11 65 // decimal 0101 // octal 0x41 // hexadecimal
Background image of page 2
Floating Point Numbers Represent numbers with decimal fractions and/or exponents Can include either or both a decimal point an e character (exponent) Examples: 12 3.14159 // 3.14159 6e23 // 6 x 10^23 1.6e-19 // 1.6 x 10^-19 3.0 // 3.0
Background image of page 3

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

View Full DocumentRight Arrow Icon
Character Constants Represent a single character Written as a single character within a pair of single quotes Examples: Can also be expressed using a backslash character
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/26/2011 for the course BENG 1002 taught by Professor Dr.x during the Winter '10 term at HKU.

Page1 / 8

2. C++ basics (updates) - Constants Constants are...

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

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