# $@ is the list of targets (the thing before the colon)
# $^ is the list of dependencies (the things after the colon)
%.o: %.c
gcc -O2 -c $^ -o $@
# Compiles directly to a target.
%: %.c
gcc -O2 $^ -o $@
# The sieve_example program depends upon both using_sieve.o and sieve.o
# $^ expands to 'using_sieve.o sieve.o'
# $@ expands to 'sieve_example'
sieve_example: sieve_main.o sieve.o
gcc $^ -o $@
debug_sieve_example: debug_sieve_main.o debug_sieve.o
gcc $^ -o $@
```
---
## Quiz Review
* The quiz content will be through today's lecture
* We'll have one more lecture before the quiz, but the content won't be on the quiz
* We'll go through a few examples
* But remember, I may ask other things, these are just examples
---
## Q1
What is the output of the following code snippet?
printf("6 / 4 = %i\n", 6/4);
a. 1
b. 1.5
c. 1.0
d. This code is not syntactically correct and will not compile.
---
## Q1
What is the output of the following code snippet?
printf("6 / 4 = %i\n", 6/4);
**a. 1**
b. 1.5
c. 1.0
d. This code is not syntactically correct and will not compile.
---
## Q2
Using the code below, if an instance of the nicePtr struct is passed into someFunction, which statement is **true**?
```
typedef struct nicePtr nicePtr;
struct nicePtr {
unsigned long* memory;
size_t elements;
};
void someFunction(nicePtr p);
```
a. The values of the array pointed to by p.memory will be copied automatically.
b. The value of p.memory will be copied, but this will not copy the elements of the array.
c. The typedef has an error and this will not compile.
d. Structs must be passed as pointers, so this will not compile.
---
## Q2
Using the code below, if an instance of the nicePtr struct is passed into someFunction, which statement is **true**?
```
typedef struct nicePtr nicePtr;
struct nicePtr {
unsigned long* memory;
size_t elements;
};
void someFunction(nicePtr p);
```
a. The values of the array pointed to by p.memory will be copied automatically.
**b. The value of p.memory will be copied, but this will not copy the elements of the array.**
c. The typedef has an error and this will not compile.
d. Structs must be passed as pointers, so this will not compile.
---
## Q3
Which of the following statements of the stack and heap is **false**?
a. Stack memory and heap memory grow from opposite ends of the memory space.
b. Heap memory is allocated and freed by the user.
c. Stack memory is allocated and freed by the user.
d. Variable length arrays may allocate memory on the stack or the heap.
---
## Q3
Which of the following statements of the stack and heap is **false**?
a. Stack memory and heap memory grow from opposite ends of the memory space.
b. Heap memory is allocated and freed by the user.
**c. Stack memory is allocated and freed by the user.**
d. Variable length arrays may allocate memory on the stack or the heap.
---
## Q4
The exit status of a program is NOT:
a. Always an integer.
b. Generally nonzero to indicate failure.
c. The value of the last variable cleaned up from the stack.
d. The value returned from the main function.
---
## Q4
The exit status of a program is NOT:
a. Always an integer.
b. Generally nonzero to indicate failure.
**c. The value of the last variable cleaned up from the stack.**
d. The value returned from the main function.
---
## Q5
After the following line of code, what is the value of a?
```
int a = 2.7;
```
a. 2.7
b. 2
c. The value will be architecture specific.
d. This code is not syntactically correct and will not compile.
---
## Q5
After the following line of code, what is the value of a?
```
int a = 2.7;
```
a. 2.7
**b. 2**
c. The value will be architecture specific.
d. This code is not syntactically correct and will not compile.
---
## Q6
Which of the following statements about argc and argv are **false**?
a. The values of argc and argv are only known at run time.
b. The main function must have argc and argv as arguments to compile.
c. argv is a pointer that points to other pointers.
d. argv[0] is the program name itself.
---
## Q6
Which of the following statements about argc and argv are **false**?
a. The values of argc and argv are only known at run time.
**b. The main function must have argc and argv as arguments to compile.**
c. argv is a pointer that points to other pointers.
d. argv[0] is the program name itself.
---
## Q7
```
#include
int main(int argc, char** argv) {
printf("%lu\n", sizeof(int*));
return 0;
}
```
The above code will:
a. Print the size of a pointer on the current architecture.
b. Print the size of an int on the current architecture.
c. It will not compile because sizeof cannot be used with int*.
d. It will not compile for other reasons.
---
## Q7
```
#include
int main(int argc, char** argv) {
printf("%lu\n", sizeof(int*));
return 0;
}
```
The above code will:
**a. Print the size of a pointer on the current architecture.**
b. Print the size of an int on the current architecture.
c. It will not compile because sizeof cannot be used with int*.
d. It will not compile for other reasons.
---
## Q8
```C
int a = 6;
int *b = &a;
b[0] = 2;
*b += 10;
```
After the above, code, what is the value of a?
a. 6
b. 12
c. 16
d. None of those.
---
## Q9
```C
int a = 6;
int *b = &a;
b[0] = 2;
*b += 10;
```
After the above, code, what is the value of a?
a. 6
**b. 12**
c. 16
d. None of those.
---
## Q10
In a little endian system, the first byte of an integer is
a. Always set to 0
b. Where the sign bit is stored
c. The least significant
d. The most significant
---
## Q10
In a little endian system, the first byte of an integer is
a. Always set to 0
b. Where the sign bit is stored
**c. The least significant**
d. The most significant
---
## Q11
What is the 2's complement negation of the byte value 0000 0001?
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_