# Chapter 14 - Worked Exercises 1

## Exercise 1 - Preprocessor & Compiler

1. What is the preprocessor?&#x20;
2. How are preprocessor directives declared/defined?&#x20;
3. Is the following statement true? Macros can be defined to compute certain values at compile time.&#x20;
4. What is the effect of an `#include` statement?

## Exercise 2 - Macros&#x20;

1. What is the syntax for declaring a macro constant? Show an example of declaring a macro constant, and using it in a program.&#x20;
2. List 2 issues that come with using macro constants.&#x20;
3. What is the preferred method of defining/declaring program-wide constants?&#x20;

## Exercise 3 - Preprocessor Output

Study each of the code snippets below, and write the preprocessor output of the following programs:

```cpp
#define VALUE_X 10
#define VALUE_Y 20

int main() {
    int a = VALUE_X;
    int b = VALUE_Y;
    int c = a + b;
}
```

```cpp
#ifndef TEST 

#define VALUE_X 10
#define VALUE_Y 20 

#else

#define VALUE_X 100
#define VALUE_Y 200

#endif


int main() {
    int a = VALUE_X;
    int b = VALUE_Y;
    int c = a + b;
}
```

```cpp
#define TEST
#ifndef TEST 

#define VALUE_X 10
#define VALUE_Y 20 

#else

#define VALUE_X 100
#define VALUE_Y 200

#endif


int main() {
    int a = VALUE_X;
    int b = VALUE_Y;
    int c = a + b;
}
```
