Title: Informatik 1 / C++

Q: ::
A: Precedence | Operator       type | Operator | Description | Associativity
1 | Unary    prefix | :: | Scope  resolution | L→R

Q: ++
A: Precedence | Operator type | Operator | Description | Associativity
2 | Unary suffix, inc. | ++ | Suffix increment | L→R

Q: --
A: Precedence | Operator type | Operator | Description | Associativity
 |  |  |  | L→R
2 | Unary suffix, dec. | -- | Suffix decrement |

Q: ()
A: Precedence | Operator type | Operator | Description | Associativity
 |  |  |  | L→R
2 | Unary suffix | () | Function call |

Q: []
A: Precedence | Operator type | Operator | Description | Associativity
 |  |  |  | L→R
2 | Unary suffix | [] | Array subscripting |

Q: ++
--
!
(bool)
(int)
(double)
(char)
A: Precedence | Operator type | Operator | Description | Associativity
3
Unary prefix, inc. Unary prefix, dec. Unary prefix, logical Unary prefix, cast id.
id. id.
++
--
!
(bool)
(int)
(double)
(char)
Prefix increment
Prefix decrement Logical NOT Conversion to boolean Conversion to integer Conversion to double Conversion to character
R→L

Q: *
/
%
A: Precedence | Operator type | Operator | Description | Associativity
5 | Binary, arithmetic id. id. | * / % | Multiplication Division Modulo | L→R

Q: +
-
A: Precedence | Operator type | Operator | Description | Associativity
6 | Binary, arithmetic id. | + - | Addition Subtraction | L→R

Q: <
<=
>
>=
A: Precedence | Operator type | Operator | Description | Associativity
8
Binary, comparison
id.
id.
id.
<
<=
>
>=
Less than
Less than or equal to Greater than
Greater than or equal to
L→R

Q: ==
!=
A: Precedence | Operator type | Operator | Description | Associativity
9 | Binary, comparison id. | == != | Equal to Not equal to | L→R

Q: &&
A: Precedence | Operator type | Operator | Description | Associativity
13 | Binary, logical | && | Logical AND | L→R

Q: ||
A: Precedence | Operator type | Operator | Description | Associativity
14 | Binary, logical | || | Logical OR | L→R

Q: ?:
A: Precedence | Operator type | Operator | Description | Associativity
15 | Ternary, conditional | ?: | Ternary condition | R→L

Q: =
+=
-=
*=
/=
%=
A: Precedence | Operator type | Operator | Description | Associativity
16
Binary,    assignment
 id.
 id.
 id.
 id.
 id.
=
+=
-=
*=
/=
%=
Assignment
Assignment by sum
Assignment by difference
Assignment by product
Assignment by quotient
Assignment by remainder
R→L

Q: ,
A: Precedence | Operator type | Operator | Description | Associativity
18 | Binary | , | Comma | L→R

Q: cout
A: Channel out (or console out); this is the output channel to print something by default to screen

Q: cin
A: Channel in (or console in); this is the input channel to
save something into a variable, by default from the keyboard

Q: int
A: Integer; used to specify the type of variable

Q: iostream
A: Input output stream; is a library to treat input and output streams elegantly

Q: endl
A: end of line; this statement is used to insert a line break

Q: #include <..>
A: Tells the processor that a certain library is needed

Q: g++
g++ -Wall
g++ -o
A: - Name of the compiler
- Compiler would also print all warning messages
- Enables to define the (executables) programs name

Q: do{...} while(...)
A: Loop which does something as long as the condition in while is fulfilled; it is done at least once, even if condition was not met in the beginning

Q: //
A: Comment tool: everything behind is treated as a comment and not part of the code

Q: /* ... */
A: Comment tool: everything in between will be read as a comment and not part of the code itself

Q: if(...){...} ... else if(...){...} else{...}
A: Will check the condition in if, if not met, go to else if, if this is not met, do what is defined in else

Q: <ctr> c
A: Kills program immediately

Q: ;
A: Terminates a statement; alone it is the null statement --> do nothing

Q: Main types
A: - bool (boolean value i.e. true or false)
- int (integer value, positive, zero or negative)
- double (real value in double precision)
- char (single character)
- char[] (string of characters)

Q: {...}
A: Compound statement

Q: while(...){...}
A: As long as the condition is met, the compound statement is executed iteratively

Q: for(...){...}
A: Needs initialising statement, condition statement and iteration statement, which is done after every block statement and the for loop is done as long as the condition statement is fulfilled

Q: setw(num)
A: Before cout this guarantees that the value printed will occupy a field of num characters.

Q: cast
A: (type) will convert the operant at their right to the indicated type. If the type is bool zero will give false and any other number true and vice versa. Converting double to int will truncate the value.

Q: return
A: Followed by a variable (except function type void) will immediately exit the function and return the variable.

Q: void
A: Function type that returns nothing. Can also be used to say that a function has no arguments f(void).

Q: exit(n)
A: Directly exit to UNIX, typically with an error message. n is an integer that will be returned to UNIX.

Q: by value
A: Pass  an argument by value will allow the function to change the value only inside the function but it will stay the same outside.

Q: by reference --> add & before variable name
A: Passing a variable by reference will allow the function to change it also outside the function. Allows the function to "return" more than one value from within. Passing by reference is also the standard way how arrays are given to functions.

Q: ::variable
A: Scope resolution --> will access the global variable instead of the default local one

Q: const variable
A: Will generate a constant variable that cannot be changed in the program. Very useful for declaring global constants which are used multiple times throughout the program but should not be changed.

Q: \0
A: Termination character: Irrespective of the length of the array, the text is over if a termination character is encountered.

Q: \t
A: tab

Q: \n
A: Newline

Q: cerr
A: Writes to error.

Q: Preprocessor instruction
A: Preprocessing is an additional step applied prior to compilation f. ex. #include<iostream>

Q: keywords
A: Have a specific meaning and belong to the C++ vocabulary f. ex. int

Q: using namespace std;
A: Enables direct access to the input-output functions cin and cout

Q: int main(){
 ...;
 ...;
 return 0;
}
A: This is the function called when the program is called; returns integer (0 usually means normal termination) and usually has no function parameters

Q: Symbol separaters
A: Any succession of blank, tab or newline characters; i.e. the compiler does not care much about the aestethics of your program formatting (but you shoud because it affects a lot its readability)

Q: Identifier
A: - Basic text unit in a C++ program
- any sequence of characters; not starting with a digit!
- some identifiers are reserved to indicate specific instructions in C++ and termed keywords --> you cannot use them for anything else

C and C++ keywords:

Q: sizeof()
A: - preprocessor command
- returns the size in bytes of a type

Q: \v
A: special character: vertical tab

Q: \a
A: Special character: audible alert (beep)

Q: Character constant
A: Consists of a single character enclosed by single quotes

Q: String constant
A: An arbitrary sequence od characters enclosed by double quotes

Q: Initialise
A: When a variable is assigned a value for the first time

Q: Explicit constant
A: Simplest form of assignment/initialisation f. ex int bla1 = 1

Q: ,
A: Binary operator; evaluates the two expressions in turn from left to right --> separate two expressions

Q: declaration statement
A: Declares the existence and type of a variable

Q: expression statement
A: Evaluates an expression

Q: Compound statement
A: A sequence of statements to be treated by the compiler as a single argument {...} --> the only statement not closing with a semicolon (but of course has semicolons within)

Q: Conditional statement
A: A statement that is only executed if some specified condition is satisfied

Q: Iterative statement
A: A statement that is executed multiple times as long as some continuation condition is satisfied (or equivalently, until some termination condition is met)

Q: Switch statement
A: Is an elegant alternative to multiple successive if-else statements

Q: cmath
A: Standard math function library

Q: Design
A: Define problem/algorithm clearly, draw flowchart, write pseudo-code, progressively fill in real code

Q: Programming
A: Make your C++ source code file(s)

Q: Preprocessing
A: For each file, expand macros, insert header files and discard comments

Q: Compiling
A: Translate source code file into object file

Q: Linking
A: Assemble the object files, possibly including additional object files from libraries, into an executable file

Q: Loading
A: Transfer executable into computer memory

Q: execution
A: Execute the executable

Q: Analysis
A: Interpret the results generated by the program

Q: Gnu compiler
A: g++ compiler; automatically preprocesses, compiles objects and does the linking producing directly an executable

Q: Typing the name of the executable
A: Promotes the loading into memory and the execution of the program; you may need to specify the absolute path if the system does not know by default where to look i.e. ./executable_name