Skill Building Exercises

 < Day Day Up > 



  1. Memory Representation: Draw the memory representation for a statically allocated three dimensional array of integers.

  2. Static Array: Write a program that declares a static array of ints with ten elements. Prompt the user to enter ten integer values. Store each value in the array and print the contents of the array to the screen.

  3. Static Arrays: Write a program that declares five static arrays of ints each with ten elements. Use an initializer list to initialize each array to the following values. Print the values to the screen.

    0, 0, 0, 0, 0, 0, 0, 0, 0, 0  1, 2, 3, 0, 0, 0, 0, 0, 0, 0 7, 9, 10, 125, 256, 3, 25, 67, 78, 9 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 12, 23,45, 0, 0, 4, 5, 0, 8
  4. Array of Pointers: Write a program that creates an array of integer pointers 5 elements long. Use an initializer list to set each pointer to NULL. Use a for loop to create the integer objects and assign their addresses to each array element. Print the values of each integer object to the screen. Remember to release the memory for each dynamically created object using the delete operator.

  5. Array of floats: Write a program that creates an array of floats seven elements long. Prompt the user to enter the total of their daily expenses for seven days and assign each value to an array element. Sum the array elements to create a grand total and print the total to the screen.

  6. Array of ints: Write a program that creates a two-dimensional array of ints. Make each dimension five elements long. Initialize each element value to zero using an initializer list. Use a nested for statement to print the contents of the array to the screen so that it looks similar to this:

    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  7. String Processing: Write a program that creates a char array 25 elements long. Prompt the user to enter a short character string and assign the string to the array. Reverse the order of characters in the array and print the results to the screen.

  8. Dynamic Arrays: Write a program that creates a dynamic array of ten integer pointers. Prompt the user to enter ten numbers and dynamically create each integer object using the value entered by the user. Print the integer object values to the screen. Also print the pointer values. Remember to release all dynamically allocated memory.

  9. Dynamic Array: Write a program that creates a dynamic array of integer objects. Prompt the user to enter the size of the array, and then prompt the user to enter the values for each integer. Sum the contents of the array and print the results to the screen. Remember to release all dynamically allocated memory before exiting the program.

  10. String Concatenation: Write a program that creates two char arrays. Prompt the user to enter two short character strings and store one string in each array. Print the contents of each array to the screen. Next, calculate the size of each sting and create a dynamic array large enough to hold both strings and combine the two. Print the combined string to the screen.



 < 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