Programming Fundamentals Flashcards

1
Q

Compiler

A

translate high-level language into machine language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

levels of programming languages

A
  • higher level language
  • assembly language
  • machine lanuage
  • hardware
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

generations of programming language

A
  • first: machine code → 0,1
  • second: assembly language → MV, R1, R2
  • third: C++, Java → IF TRUE THEN, END IF;
  • fourth: SQL, assorted artificial intelligence language → SELECT FIRST_NAME FROM EMPLOYEE;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

C++ programming language

A
  • general purpose programming language
  • based on keywords
    // → comments
    #include → pre-processor instruction to include code of standard library
    int main(0) → declaration of function
    {…..} → statement specifiying behaviour of program
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

variables

A

defined in programming language, used to perform operations
- name & type → determines operations possible to perform
- variable declaration: int numberOfStudents;
bool → boolean [TRUE, FALSE]
char → character [‘a’, ‘n’, ‘3’]
int → integer [1, 30, 4578]
double → floating point number [3.29, 1.57]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

values

A

assigend to variale name via assignment operator “=”
- variable assignment: numberOfStudents=200;
one might initialise variable when declaring it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

type sizes

A
  • corresponds directly to hardware facilities
  • fixed size that determines range of values that can be stored
    bool → 1 byte (8 bit)
    char → 1 byte
    int → 4 bytes
    double → 8 bytes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

array data strucutre

A

store collection of values of a given type

- char v[6] → array of 6 characters → 6 bytes to store character in

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

control structures

A

selection: decision which pathway is taken → TRUE & FALSE
- if & switch (depending ong implemented case different outcome)
iteration (loop): repeat certain path whilst true
- while → as long as condition is true, command is repeated
- for → repeat for a certain amount
sequence: one command after another

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

function declaration

A
Functions require a delcaration to be called
- declaration: give the name of the function, type of value returned, number of types of arguments
void exit(int); → int argument and return nothing
double sqrt(double); → double argument & return double
double s2 = sqrt(2); → call sqrt with argument double {2}
double s3 = sqrt("three"); → error
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

motivation for functions

A
  • break up complicated & long computations into meaningful chunks & name them
  • coding recommendation for one function: 40 lines/7 lines
    goal: comprehensible
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Function definitions

A
  • every function must be defined somewhere
  • need to be defined once
  • function definition is a function declaration in which the body of the function is presented
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

C++ vs. python

A
python
- young language
- easy use and readability
- "write once, use anywhere"
- has to be interpreted → slower
C++
- more complicated
- easily transferable to wide variety of applications
- need to be complie on application system before it can execute
- nearer to the hardware → faster
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

threshold binary

A

values above a certain threshold are 1/”TRUE”, values below are 0/”FALSE”
→ loss of information

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

threshold to zero

A

only values below threshold are 0

→ information is preserved

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

pass by reference

pass by value

A

pass by reference: change the reference → also change what we defined before
- e.g. double& x
pass by value: copy the value and get a new address; can be changed while the defined value (in the determination) does not change
e.g. int y