SCC111: weeks 1-5 Flashcards

(24 cards)

1
Q

what is imperative programming?

A

a programming paradigm that uses statements that change a program’s state

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

what is declarative programming?

A

programs described the desired result without necessarily explaining what steps should be performed.

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

what is the main difference between imperative and declarative programming?

A

-imperative describes how a problem should be solved
-declarative declares the problem that needs to be solved

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

what type of programming paradigm is C?

A

an imperative paradigm

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

key features, benefits of C

A

-compact
-low-level
-fast and efficient code
-code can exploit hardware components efficiently

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

what is meant when we say C is a compiled language?

A

-compiler is used to translate syntactically correct source code into an executable (binary) file

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

how can other people’s code be referenced in your code?

A

include statements

— eg #include <stdio.h></stdio.h>

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

list the binary operators and their meanings

A

-Addition: +
-Subtraction: -
-Division: /
-Multiplication: *
-Remainder (mod): %
-logical shift left/right: «/»

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

list the unary operators and their meanings

A

-Increment: ++
-Decrement: –
-Add: +=
-Multiplication: *=

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

list the logical operators

A

-less than: <
-greater than: >
-less than/equal to: <=
-greater than/equal to: >=
-not/equal to: !=/==
-not: !
-and: &&
-or: ||

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

what is the benefit of a do while loop?

A

changes where the validation for doing the while loop is found. means code in the loop is executed at least once.

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

how would you leave a loop early?

A

by using ‘break’

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

how would you skip to the next iteration of a loop?

A

by using ‘continue’

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

what constitutes the scope of a variable?

A

the portion of code from which it can be referenced/accessed

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

how is an array declared in C?

A
  • int listOfInts[number_of_values];
    or
    -int listOfInts[3] = {1,2,3};
    or
    -int listOfInts[] = {1,2,3,4};
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what needs to be considered when devising a test case?

A

-boundary cases
-invalid cases
-uncertain values

17
Q

what are some techniques for debugging?

A

-dry-running
-hypothesis testing (tracking variable values)
-runtime debugging (setting breakpoints, using debugger)

18
Q

what is the programming technique typically used for indirection?

19
Q

what is a pointer?

A

-a variable that holds the address of something else
-could be the address of a variable, process or object

20
Q

what is the concept of pass by reference vs pass by value?

A

-to pass by reference a pointer is passed as a parameter. This means the value at the specified memory address can be modified.
-when passing by value, the variable is passed to a function. When the variable is referenced within the process, a copy of the variable is used.

21
Q

how would you create an integer pointer x, that points to address of variable y?

22
Q

if x is a pointer to a memory location y, how can we set y to 65 using x?

23
Q

what process is done in the line *x = 65; ?

A

dereferencing