Previous: 7.9 Exercises
Up: 7 Arrays
Previous Page: 7.9 Exercises

7.10 Problems

  1. Write a program that uses the sizeof operator to print the size of an array declared in the program. Use the sizeof operator on the name of the array.

  2. Write a function that prints, using dereferenced pointers, the elements of an array of type float.

  3. Write a function that checks if a given integer item is in a list. Traverse the array and check each element of the list. If an element is found return True; if the array is exhausted, return False.

  4. Write a function that takes an array of integers and returns the index where the maximum value is found.

  5. Write a function that takes an array and finds the index of the maximum and of the minimum.

    Use arrays to house sets of integers. A set is a list of items. Each item of a list is a member of a list and appears once and only once in a list. Write the following set functions.

  6. Test if a number is a member of a set: is the number present in the set?

  7. Union of two sets A and B: the union is a set that contains members of each of the two sets A and B.

  8. Intersection of two sets A and B: the intersection contains only those members that are members of both the sets A and B.

  9. Difference of two sets A and B: The new set contains elements that are members of A that are not also members of B.

  10. Write a function to read a string from the standard input. Read characters until a newline is reached, discard the newline, and append a NULL. Use array indexing.

  11. Write a function to read a string from the standard input. Read characters until a newline is reached, discard the newline, and append a NULL. Use pointers.

  12. Write a function to write a string to the standard output. Write characters until a NULL is reached, discard the NULL, and append a newline. Use pointers.

  13. Write a function to change characters in a string: change upper case to lower case and vice versa. Use array indexing.

  14. Write a function to change characters in a string: change upper case to lower case and vice versa. Use pointers.

  15. Write a function that counts and returns the number of characters in a string. Do not count the terminating NULL. Use array indexing.

  16. Write a function that counts and returns the number of characters in a string. Do not count the terminating NULL. Use array indexing.

  17. Write a function that removes the last character in a string. Use array indexing to reach the last element and replace it with a NULL.

  18. Write a function that removes the last character in a string. Use pointers to traverse the array.

  19. Repeat problems 24 and 25, but use the function of problems 22 or 23.



Previous: 7.9 Exercises
Up: 7 Arrays
Previous Page: 7.9 Exercises

tep@wiliki.eng.hawaii.edu
Wed Aug 17 08:56:22 HST 1994