From 2e3053784b56e38fbd7aecbfb264088f75386db7 Mon Sep 17 00:00:00 2001 From: zleyyij <75810274+zleyyij@users.noreply.github.com> Date: Fri, 1 Nov 2024 13:18:59 -0600 Subject: [PATCH] vault backup: 2024-11-01 13:18:59 --- .../ECE1400/(not) Chapter 11 Exercises.md | 20 ++++++++++++++++ .../ECE1400/Chapter 11 Exercises.md | 24 +++++-------------- 2 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 education/software development/ECE1400/(not) Chapter 11 Exercises.md diff --git a/education/software development/ECE1400/(not) Chapter 11 Exercises.md b/education/software development/ECE1400/(not) Chapter 11 Exercises.md new file mode 100644 index 0000000..4dcdc59 --- /dev/null +++ b/education/software development/ECE1400/(not) Chapter 11 Exercises.md @@ -0,0 +1,20 @@ +1. Suppose that the following declarations are in effect:.... + a. `14` + b. `34` + c. `4` + d. `true` + e. `false` + +2. Suppose that `high`, `low`, and `middle` are all pointer variables of the same type, and the `low` and `high` point to elements of an array. Why is the following statement illegal, and how could it be fixed? +```c +middle = (low + high) / 2 +``` +The above statement is illegal because you can't add an `int *` to an `int *`. The below operation is legal because you can perform pointer subtraction, and because `low` is defined on the left hand side of the equation, then adding a long to a pointer is valid. +```c +middle = low + (high - low) / 2; +``` + +3. What will be the contents of the `a` array after the following statements are executed? +```c +{10, 9, 8, 7, 6, 5, 4, 3, 2, 1} +``` \ No newline at end of file diff --git a/education/software development/ECE1400/Chapter 11 Exercises.md b/education/software development/ECE1400/Chapter 11 Exercises.md index 4dcdc59..68d5183 100644 --- a/education/software development/ECE1400/Chapter 11 Exercises.md +++ b/education/software development/ECE1400/Chapter 11 Exercises.md @@ -1,20 +1,8 @@ -1. Suppose that the following declarations are in effect:.... - a. `14` - b. `34` - c. `4` - d. `true` - e. `false` +> 1. If `i` is a variable and `p` points to `i`, which of the following expressions are aliases for `i`? -2. Suppose that `high`, `low`, and `middle` are all pointer variables of the same type, and the `low` and `high` point to elements of an array. Why is the following statement illegal, and how could it be fixed? -```c -middle = (low + high) / 2 -``` -The above statement is illegal because you can't add an `int *` to an `int *`. The below operation is legal because you can perform pointer subtraction, and because `low` is defined on the left hand side of the equation, then adding a long to a pointer is valid. -```c -middle = low + (high - low) / 2; -``` +a. `*p` +g. `*&i` -3. What will be the contents of the `a` array after the following statements are executed? -```c -{10, 9, 8, 7, 6, 5, 4, 3, 2, 1} -``` \ No newline at end of file +> 2. If `i` is an `int` variable and `p` and `q` are pointers to `int`, which of the following assignments are legal? + +a. \ No newline at end of file