Chapter 9 Exercise Set 0: Chapter Review and Exploration¶
Make a file named
swaps.cpp
that includes all three versions of swap functions presented in the chapter with calling code inmain
. Compile and then run your program several times, observing what happens.Write a function named
shuffle
, that takes an array as an argument and randomly “shuffles” the elements in the array. You can create two versions of this function, one that is a modifier and one that is a pure function.Write a function named
str_len
that takes a C string as an argument and returns the number of characters in the string.Read Heap vs. Stack Memory and prepare a summary presentation of the key difference between stack memory and heap memory and the times and reasons for using each.
Write a program named
talkin_trash.cpp
that illustrates the two concepts of arrays being memory unsafe and garbage in, garbage out discussed in the chapter. Be creative. The best solution to this exercise will be a program example that helps others reading your code understand these two concepts.