L2 - Arrays Flashcards

1
Q

clang

A

Compiler we’re using when we run the program make/ code

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

How do you link libraries with a command line argument when compiling with clang?

A

-l
clang -o hello hello.c -lcs50
This links and renames the file

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

What are the four steps to turn source code into binary?

A
  1. pre-processing
  2. compiling
  3. assembling
  4. linking
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Pre-Processing

A

Converts the included libraries (#include <stdio.h>) and adds the prototypes to the top of the file to be able to use all functions in that .h file</stdio.h>

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

Compiling

A

Convert source code to assembly code.

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

Assembling

A

Takes assembly code and converts to 0/1s

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

Linking

A

Pulls all 0/1s in all of the files together.

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

Debugging

A

Running through code to figure out issues.

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

Break point.

A

Point to pause execution of code, which is by adding a dot in the gutter. It stops at the first line of executable code, on or right after the breakpoint. The highlighted code has not been run yet.

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

Garbage values

A

Values that are present before variables are set.

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

Step over

A

Execute but don’t get into full detail.

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

Step in

A

Walkthrough the function step by step in detail

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

Step out

A

Pulls you out of the step by step detailed function to execute without full details.

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

Arrays

A

Sequence of values stored in memory without any gaps in between them with a 0 index, so position 1 is 0.

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

What is this?
int scores [3];

A

declaration of an integer array called “scores”, with a length of 3

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

Initialize an array

A

int scores [3];
Data type. Name. Array size.

17
Q

assign a value to an int array

A

score[0]=72;
This cerates an int array and assigns 72 to index 0 (first position) of the array

18
Q

constant

A

const Variable
This prevents the variable from being changed during the execution of the program and should start with a capital letter.

19
Q

What is the prototype for a function that takes in an integer value and an array?

A

int average(int length , int array[]);

20
Q

What is special about chars/ints?

A

chars can return the int numeric value, and ints can return the char letter/symbol values

21
Q

Length of a string

A

N+1
(Length+1)

22
Q

NUL or /0

A

byte with all zero bits (00000000) which indicates the end of a string, so the length of the string is always it’s length+1
NUL is not the same as NULL

23
Q

How to use command line arguments to get input from a user with your main function

A

int main (int argc, string argv[])
Pronounced arg c and arg v

24
Q

what is argc in main function?

A

Argument count:
The number of words the user typed in the command line prompt to run the program
ex: ./hello Bianca
argc = 2 since the filename is always the string in argc

25
Q

what is argv in main function?

A

Argument vector array:
Takes the data entered when running the program and stores it into an array starting with the filename as index 0

26
Q

exit status

A

The value returned when a program finishes running. A zero always means the program ran successfully and exited correctly. Any other value means an error occurred.

27
Q

return 0;

A

Can be used to exit a program

28
Q

echo $?

A

Can be used as a command line prompt to see the most recently executed program’s exit code.

29
Q

Cryptography

A

Scrambling data that needs to be unlocked with a key to figure out the message

30
Q

initialize an int array with the values 1,3,2,4,2

A

int numbers[5]={1,3,2,4,2};
data type.name. square brackets. size. =. curly braces. comma separated numbers. semicolon