Programming Exercises

  1. Some users might be daunted by being asked to enter an EOF character. Modify getarray() so that a # character terminates input the first time it is entered.

  2. Create a program that sorts float numbers in increasing order.

  3. Modify the sort() function in Listing 13.12 so that it uses the suggestion given in the "Comments" section following the sample output; namely, that the function keep track of the index of the largest value and swap values only after the inner loop terminates.

  4. Write and test in a loop a function that returns the number of times it has been called.

  5. Write a program that generates a list of 100 random numbers in the range 1–10 in sorted decreasing order.

  6. Write a program that generates 1,000 random numbers in the ...

Get C Primer Plus®, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.