01 C++ Programming Languag
01 C++ Programming Languag
Basics
Very brief history of C++
C++
“If you’re not at all interested in performance,
When to choose C++ shouldn’t you be in the Python room down the hall?”
― Scott Meyers (author of Effective Modern C++)
Compiler creates
Compiler object code and stores
2. Preprocess
Disk
it on disk.
3. Compile
Linker Disk creates a.out and
stores it on disk
Primary
4. Link Loader
Memory
5. Load Disk ..
in memory.
..
6. Execute
..
Primary
Memory
CPU CPU takes each
instruction and
executes it, possibly
storing new data
values as the program
.. executes.
..
..
1 // Fig. 1.2: fig01_02.cpp
First 5
6
int main()
am 10 }
includes
C++ input/output
programs
the
one ofscreen).
operations
contain one
which must be main
(such as printing
or more functions, exactly to
• << \t
Horizontal tab. Move the screen cursor to the next
tab stop.
• stream insertion operator Carriage return. Position the screen cursor to the
\r beginning of the current line; do not advance to
• value to the right of the operator (right the next line.
operand) inserted into output stream (which \a Alert. Sound the system bell.
is connected to the screen) \\ Backslash. Used to print a backslash character.
std::cout << " Welcome to C++!\n" \"
Double quote. Used to print a double quote
character.
•\
• escape character
• indicates that a “special” character is to be
output
Keywords
• Keywords also known as reserved words
• It has special meaning to compiler and used for special purpose
• All keywords are written in lower case
• Below list of keywords are additional in C++
Identifiers
• Identifiers are used to refer to name of variable, functions, arrays and
other user-defined data types
• Rules for Identifiers
• Only alphabetic characters, digits and underscore is allowed
• First character can’t be digit of identifier
• A keyword can’t be used as identifier
• Identifiers are case sensitive
ULONG_MAX
sizeof() operator: sizeof() operator is used to find the number of Maximum value for an object of type Unsigned long int
bytes occupied by a variable/data type in computer memory. LLONG_MIN The minimum value for an object of type long long int