L03vars - C+ Basics Variables, Identifiers, Assignments,...

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

View Full Document Right Arrow Icon
C++ Basics Variables, Identifiers, Assignments, Input/Output
Background image of page 1

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

View Full DocumentRight Arrow Icon
Program Organization C++ program Collection of definitions, declarations and functions Collection can span multiple files Advantages Structured into small understandable units Complexity is reduced Overall program size decreases
Background image of page 2
Variables variable can hold a number or a data of other types, it always holds something. A variable has a name the data held in variable is called value variables are implemented as memory locations and assigned certain memory address. The exact address depends on computer and compiler. we think as though the memory locations are actually labeled with variable names 12.5 32 'c' y Temperature Letter 1001 1002 1003 1004 1005 1006 1007 - Number 1008 1009
Background image of page 3

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

View Full DocumentRight Arrow Icon
Identifiers name of a variable (or any other item you define in program) is called identifier identifier must start with a letter or underscore symbol ( _ ), the rest of the characters should be letters, digits or underscores the following are valid identifiers: x x1 x_1 _abc sum RateAveragE the following are not legal identifiers. Why? 13 3X %change data-1 my.identifier a(3) C++ is case sensitive: MyVar and myvar are different identifiers
Background image of page 4
What Are Good Identifiers? careful selection of identifiers makes your program clearer identifiers should be short enough to be reasonable to type (single word is norm) – Standard abbreviations are fine (but only standard abbreviations) long enough to be understandable two styles of identifiers C-style - terse, use abbreviations and underscores to separate the words, never use capital letters for variables Pascal-style - if multiple words: capitalize, don’t use underscores – Camel Case – variant of Pascal-style with first letter lowercased pick style and use consistently ex: Pascal-style C-style Camel Case Min min min Temperature temperature temperature CameraAngle camera_angle cameraAngle CurrentNumberPoints cur_point_nmbr currentNumberPoints
Background image of page 5

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

View Full DocumentRight Arrow Icon
Keywords keywords are identifiers reserved as part of the language int, return, float, double they cannot be used by the programmer to name things they consist of lowercase letters only they have special meaning to the compiler
Background image of page 6
Keywords (cont.) asm do if return typedef auto double inline short typeid bool dynamic_cast int signed typename break delete long sizeof union case else mutable static unsigned catch enum namespace static_cast using char explicit new struct virtual class extern operator
Background image of page 7

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

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

This note was uploaded on 04/22/2010 for the course CS 23021 taught by Professor Staff during the Spring '08 term at Kent State.

Page1 / 27

L03vars - C+ Basics Variables, Identifiers, Assignments,...

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

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