Lecture 2 - C Basics Flashcards

1
Q

Is C object-oriented?

A

No

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

What is the difference between Java and C when OOP is ignored?

A

How memory is managed and how the program is executed.

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

What does -Werror do?

A

Turns all warnings into errors making the program impossible to compile until all warnings have been fixed.

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

What does the -Wall flag do?

A

The -Wall flag enables most compiler warnings

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

What are make files?

A

Files that allow building of C programs automatically -> with a command.

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

Are make files C exclusive?

A

No, they can be used for any command line interface command.

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

What is the first line of a make file made up of?

A

[targets] : [sources]
- sources can be thought of as dependencies

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

What does typing make in the CLI do?

A

Execute the first command in the make file.

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

What does every C program have ?

A

An entry function called main.

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

Do we need to return anything from a main function?

A

No, 0 is automatically returned by the function.
0 indicates successful execution

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

What does a non-negative value returned from main indicate?

A

unsuccessful execution

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

What are the 2 versions of main?

A

int main() { … }
int main(int argc, char* argv[]) { … }

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

What is a C programming language?

A

A statically typed language where every variable must have a data type known without running the program.

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

What are data types?

A

A label which gives meaning to its stored in memory.

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

What do we control when choosing a specific data type?

A

The amount of memory we use, as different data types take up different amount of space.

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

How do booleans work in C?

A

0 is false and anything else is true. The data type is int.

17
Q

What do data types help with ?

A

Preserving meaning to computations and results.So only meaningful computations can be completed.

18
Q

Size of char?

A

1 byte

19
Q

Size of short / unsigned short?

A

2 bytes = 16 bits

20
Q

Size of int / unsigned int?

A

4 bytes = 32 bits

21
Q

Size of long / unsigned long?

A

4 or 8 bytes

22
Q

Size of long long / unsigned long long?

A

8 bytes

23
Q

What does the <stdbool.h> inclusion give us?</stdbool.h>

A

The ability to have a defined type of boolean (bool) in C99.
These are defined as macros

24
Q

What is a {} called in C?

A

A block

25
Q

What does {} introduce?

A

A lexical scope/

26
Q

What must be unique in a lexical scope?

A

Variable names

27
Q

What are the 3 ways of allocating variables?

A
  • automatic (declared in a local block)
  • static (declared at file level - outside all blocks). Lifetime is the entire execution of program.
  • allocated (the ones we dynamically requested)
28
Q

Do we need to manage memory for automatic variables?

A

No, it happens automatically.

29
Q

What is a struct ?

A

Structure which consists of members which could be of different data types.

30
Q

How are members in a struct stored in memory?

A

Next to each other (sequentially)

31
Q

What does every string end with in C?

A

\0, it is added automatically

32
Q

What is a function definition?

A

fully specifies the behaviour of a function

33
Q

What is a function declaration?

A

the interface describing how a function can be used

34
Q

What searches for functions when they’re not in source file (they could be in different file or library).

A

The linker

35
Q

How are arguments passed to functions in C and what does this mean?

A

Call by value , we pass a copy of arguments to function (except arrays and pointers).