Engineering Science 1036A/B Lecture Notes - Lecture 6: Reserved Word, Level Of Measurement

12 views10 pages
C++ Variables (Objects)
Memory spaces must be reserved to process data/info
Reservations are done using variable/constant names
Variables: boxes/placeholders in the memory that can hold things
Each variable has to be identified by a name, which has to be declared before using it
The name of any type of variable/constant/ function/namespace/class is called an
identifier
Size of the variable depends on the type of things we are planning to store there
We have to tell the compiler in advance (declare):
Names of each of the variables we want
The type of things that will be put in each variable
Identifier Characteristics
An identifier may consist of:
Alphabetical letters
Capital or lowercase
§
Numerical Digit (0-9)
Special characters: "_" and "$"
An identifier cannot start with a digit
An identifier cannot be a reserved word
An identifier can be of any length unless C++ complier has restrictions
Usually are under 31 characters to ensure portability
Reserved Words
Reserved words (keywords): The words which are reserved for a particular programming
language (grammar)
Each keyword has a particular meaning to the programming language
Variable Declaration
A variable has to declared by writing the name of the variable as well as the data type it
represents
Variables
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 10 pages and 3 million more documents.

Already have an account? Log in
ing
it
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 10 pages and 3 million more documents.

Already have an account? Log in
represents
Declaring a variable tells the compiler to allocate enough memory space to hold a value
of this data type and to associate the identifier with this location
Re-declaring a variable is a syntax-error in any block statement
Built-in Data Types
Mixing different data types
Numerical data types (int,float,double) cannot be mixed with non-numerical data
types (char,string)
char
Holds a single character
toupper() & tolower()
int toupper (int c);
Converts argument "c" to its uppercase equivalent if "c" is a lowercase letter
Otherwise, it returns the same letter
§
anyChracter = toupper (anyChracter);
§
int tolower (int C);
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 10 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Memory spaces must be reserved to process data/info. Variables: boxes/placeholders in the memory that can hold things. Each variable has to be identified by a name, which has to be declared before using it. The name of any type of variable/constant/ function/namespace/class is called an identifier. Size of the variable depends on the type of things we are planning to store there. We have to tell the compiler in advance (declare): Names of each of the variables we want. The type of things that will be put in each variable. An identifier can be of any length unless c++ complier has restrictions. Usually are under 31 characters to ensure portability. Reserved words (keywords): the words which are reserved for a particular programming language (grammar) Each keyword has a particular meaning to the programming language. A variable has to declared by writing the name of the variable as well as the data type it represents ing it represents.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents