chapter_6
chapter_6
• Comment line: //
Can be used at any position in the program.
All following characters of this line are regarded as a
comment and not compiled.
Volume
Content (Size/Type)
(Value)
Label
(Name)
Definition:
valid • letters a-z, A-Z, no special letters (ä,ö,ü,ß); capital and small letters allowed
characters: • digits 0-9
• underscore (‘_’)
• a distinction is made between capital and small letters
(C/C++ is case sensitive!!)
Examples:
allowed: _n, x1, x_1, Flaeche
not allowed: 1x, Fläche, x 1
not recommended: F, FLAECHE
Data Types
There are various types of glasses, each storing different types of content
‘Real’ Numbers: • floating point notation: 1.0, 0.082, 7., -2.83, +0.
• exponential notation: 1.E3, 7.082E-4
(in general: significant * 10^exponent)
Usage
in t i; // d e c la r a tio n o f a n in te g e r i
d o u b le d ; // d e c la r a tio n o f a r e a l n u m b e r d
char s;
s = ‘c ’;
char s;
s = ‘c ’; // o .k .
s = “c “; // w r o n g , a s th is s tr in g c o n s is ts o f th e tw o c h a r a c te r s ‘c ’ u n d ‘ \0 ’
6.4 Arithmetic expressions, operators
An arithmetic expression is composed of: constants, variables and operators
Example: 2_b
Attention:
It is very important to note that arithmetic expressions may perform a type casting
(or type conversion).
Type conversion
= Simple assignment i = 6;
i = j;
Examples: 2_d
Logical expressions: Relation
The relation between two arithmetic expressions aa1 und aa2
aa1 relational operator aa2
yields a condition (also: logical expression)
== equal to =
The result of a conditional statement is an integer value: 0 means false, otherwise true
Example: 3_b
More logical expressions
Logical operators:
C++-expression meaning
! not
&& and
|| or (inclusively)
(on keyboard: “Alt Gr” + “<”)
0 means that the logical value is false, all other values correspond to the
logical value true.
logical and (&&):
operand 1 operand 2 result
1 1 1
1 0 0
0 1 0
0 0 0
logical or (||):
operand 1 operand 2 result
1 1 1
1 0 1
0 1 1
0 0 0