Posts

Showing posts with the label solutions

C++ Crash Course: Solution to Exercises in Chapter 4.

Image
My solutions to the exercises at the end of Chapter 4 in Part 1 of C++ Crash Course. In this series of exercises, you will make use of a Copy Constructor, Copy Assignment Operator, Move Constructor, and a Move Assignment Operator. Pay close attention to the differences in the elapsed times of Timer 1 and Timer 2. Pay close attention to the fact that when Timer 2 is destroyed, its name will be Timer 1 because of the Copy Constructor, where you will copy Timer 1's name to Timer 2, as well as the time stamp. You will also notice that there is never an indication that Timer 3 is destroyed, but keep in mind we are moving Timer 4 to Timer 3. Therefore, when Timer 4 is destroyed, that is really Timer 3, but after having Timer 4's name moved into its name field. A little bit confusing if you try to breeze through it, but pay close attention to each line of the program, and you will understand exactly what is happening in this exercise. Github: https://github.com/pereiradaniel/CPP_CRASH...

C++ Crash Course: Solution to Exercise 3-4.

Image
My solution to Exercise 3-4 from Part 1, Chapter 3 of C++ Crash Course. This one was fairly straightforward, but it illustrates a very important thing on line 13. When you assign new_value to the reference original_ref , it assigns the value to the int that original_ref is pointing to. The result is that new_value and original both have the same value, 200. Github: https://github.com/pereiradaniel/CPP_CRASH_COURSE/blob/master/P1C3/EXERCISES/3_4.cpp Youtube: C++ Crash Course: Solution to Exercise 3-4.

C++ Crash Course: Solution to Exercise 3-3.

Image
My solution to Exercise 3-3 from Part 1, Chapter 3 of  C++ Crash Course. Github: https://github.com/pereiradaniel/CPP_CRASH_COURSE/blob/master/P1C3/EXERCISES/3_3.cpp Youtube: C++ Crash Course: Solution to Exercise 3-3.

C++ Crash Course: Solution to Exercise 3-2.

Image
My solution to Exercise 3-2 from Part 1, Chapter 3 of C++ Crash Course. Github: https://github.com/pereiradaniel/CPP_CRASH_COURSE/blob/master/P1C3/EXERCISES/3_2.cpp Youtube: C++ Crash Course: Solution to Exercise 3-2.

C++ Crash Course: Solutions to Exercises in Part 1, Chapter 2.

Image
My solutions to the Exercises in Part 1, Chapter 2. Github: https://github.com/pereiradaniel/CPP_CRASH_COURSE/tree/master/P1C2/EXERCISES Video: C++ Crash Course: Solutions to Exercises in Part 1, Chapter 2.

C++ Crash Course: Solutions to Exercises in Part 1, Chapter 1.

For the last while, I have been busy with ESP32 and Arduino programming, but now I finally have time to ram through this book and the exercises. There are a few repositories on Github where people have offered solutions to some of these exercises, but I find that they are often not complete. Therefore, I am endeavouring to make a more complete listing, or at least fill in some of the holes. Here is a video and a link to the repository for the solutions to Part 1, Chapter 1. The exercises can be found at the end of each chapter. I am back-tracking a bit from where I am in Part 1 Chapter 5, which is where I am currently studying. Github: https://github.com/pereiradaniel/CPP_CRASH_COURSE/tree/master/P1C1/EXERCISES Video: C++ Crash Course: Solutions to Exercises in Part 1, Chapter 1.

C: Exercise 4-3 improved by splitting ascending/descending loop into two...

Image
Improvement to exercise 4-3 using a different type of switchable for loop, with compiler examination.  Repl: https://replit.com/@pereiradaniel/Improved-asc-desc-for-loop-added-to-existing-project Git repo: https://github.com/pereiradaniel/beginning_c/blob/master/ch4/exercises/4_3/refactor5.c  

C: Improve exercise 4-3 with improved ascending/descending for loop.

Image
Improvement to exercise 4-3 using a different type of switchable for loop, with compiler examination.  Repl: https://replit.com/@pereiradaniel/Improved-asc-desc-for-loop-added-to-existing-project Git repo: https://github.com/pereiradaniel/beginning_c/blob/master/ch4/exercises/4_3/refactor5.c  

C: Exercise 4-3, sort by ascending or descending order.

Image
Added sorting by ascending or descending order. Repl: https://replit.com/@pereiradaniel/Exercise-4-3-refactor-4 Git repo: https://github.com/pereiradaniel/beginning_c/blob/master/ch4/exercises/4_3/refactor4.c

C: Exercise 4-3 improvements of refactor 3.

Image
Improvement of this program: https://youtu.be/1_ER9Gzsglw Repl: https://replit.com/@pereiradaniel/Exercise-4-3-refactor-3 Git repo (this project):  https://github.com/pereiradaniel/Exercise-4-3-refactor-3 Git repo (archive of projects):  https://github.com/pereiradaniel/beginning_c