Lec4 - Lecture 4 The basics of C+ Variables names types...

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

View Full Document Right Arrow Icon
Lecture 4 Variables, operators, assignment statements, math.h, if statements 1 Lecture 4 – The basics of C++ Variables names types Arithmetic Operators Rules Assignment Statements math.h functions if statements
Background image of page 1

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

View Full DocumentRight Arrow Icon
Lecture 4 Variables, operators, assignment statements, math.h, if statements 2 Variable names Names can have letters, digits and the underscore character No spaces and no other characters are allowed . They must begin with a letter or the underscore. They are case sensitive. Valid names h height height__1 Invalid names 1h height 1 height#
Background image of page 2
Lecture 4 Variables, operators, assignment statements, math.h, if statements 3 Variable types Name Type Example int integer 16 float floating point with 16.3452 6 digits of accuracy double floating point with 16.3451867232 12 digits of accuracy char character t bool Logical variable if true it equals 1 if false it equals 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
4 Binary arithmetic operators symbol operation + addition - subtraction * multiplication / division % remainder after division of two integers Example: 7%3=1 Note that there is no “to the power of” operator. You must use the function pow( base, exponent)
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 02/26/2008 for the course ENGR 1 taught by Professor X during the Spring '07 term at Lehigh University .

Page1 / 14

Lec4 - Lecture 4 The basics of C+ Variables names types...

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