Skill Building Exercises

 < Day Day Up > 



Note: For all exercises create separate header and implementation files. In exercises that result in more than one function, you can group the function declarations in one header file and all function definitions in one implementation file.

  1. Text Message Display: Write a simple function that displays a text message on the screen when called. Give the function a name that gives a hint of what it does. Write a program that calls the function. Hint: The function should return void and take no arguments.

  2. Print Array Contents: Write a function that takes a character array as an argument and prints the contents of the character array to the screen. Write a program that calls the function several times using different character arrays as arguments. Hint: If you use an array of chars to hold the message make sure the last character is ‘\0’.

  3. Array Reversal: Write a function that takes a character array as an argument. Print the array to the screen, then reverse the order of characters in the array and print the array to the screen again. In the same function, count the number of characters in the array and print the count to the screen. Also include a static variable that counts the number of message arrays that have been printed to the screen. Write a program to test the function.

  4. Dynamic Array: Write a function that takes two character arrays as arguments and creates a dynamically allocated array that contains the elements of both array arguments. Return the address of the dynamically allocated array. Caution: Do not forget to delete[] the array before the program ends. But, do not delete[] it in the function! Write a program to test the function.

  5. Array Parameter: Write a function that takes a character array as an argument and prints out every permutation of the array. Return the integer value corresponding to the number of permutations that were calculated. Write a program to test the function.

  6. Lotto Number Generator: Write a function that calculates every possible combination of lottery numbers. The function should take two integer arguments indicating how many numbers there are to choose from and how many numbers are required to be picked. i.e., 52 numbers to choose from, pick 6 out of 52. Return the number of possible lottery ticket combinations. Write a program to test the function.

  7. Sum of all floats: Write a function that takes an array of floats as an argument and returns the sum of the array. Write a program to test the function.

  8. Converter: Write a function that takes an integer argument and prints the binary and hexadecimal equivalent values to the screen. Write a program to test the function and convert a few integer values.

  9. Function Pointer: Write a program that creates a function pointer to the type of function you created in skill building exercise 8. Use the function pointer to call the function.

  10. Research: Research the steps involved to create a function library using your integrated development environment. Once you have figured it out, create a library from the lottery function you created in skill building exercise 6.



 < Day Day Up > 



C++ for Artists. The Art, Philosophy, and Science of Object-Oriented Programming
C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504028
EAN: 2147483647
Year: 2003
Pages: 340
Authors: Rick Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net