Beginning C++ Program Assignments

Instructor: Roseann Krane


Program 19: Days: Using enumerators for the days of the week, write a program using a switch statement that prints the name of the day of the week and a message when an integer from 1 to 7 is input.

Program 18: NewPIM: Do the same program in seventeen and use 'new' for pointers instead of arrays.

Program 17:PIM: Write a personal information manager (PIM) for yourself. Create a structure to hold information about people you know, including at a minimum, their name, address, city, state, zip, phone number, and year of birth. Using an array of these structures, input at least three people (the neighbors to your right and left and yourself), and output the information to the screen.

Program 16: MathTable: Revisit your grade school math class, and write a program that will output a multiplication table for the values 1 through 12. Store the results in a two-dimensional array and use nested for loops for the calculations and output. Hint: use the program your teacher did with you as a demonstration and modify it.

Program 15: Dereferencing: Write a program that declares two variables of type float and a single pointer of type float. First initialize the pointer to point to the first float variable. Use the dereferencing operator to initialize the variable to 1.25. Next point the pointer to the second float variable and use the pointer to initialize the variable to 2.5. Print the value of the first variable to the screen by accessing the variable directly. Print the second variable using the deferencing operator.

Program 14: While! Write a program that asks you to type in numbers. After each entry, the numbers reports the cumulative sum of the entries to date. The program terminates when you enter a zero. Must use a while loop.

Program 13: Sum. Write a program that requests the user to enter two integers. The program then should calculate and report the sum of all the integers between and including the two integers. At this point, assume that the smaller integer is entered first. For instance, if the user enters 2 and 9, the program would report that the sum of all the integers from 2 through 9 is 44. Must use a for loop.

Program 12: String. Some compilers treat string literals as read-only constants, and some compilers use one copy of a string for all occurrences of the string in the program. Write a program that demonstrates how your compiler handles this situation. Hint: I used

char strOne[] = ...... ;

char* strLoc;

Program 11: Letter grades:

Write a program that requests and displays first and last name, letter grade of A, B, or C for the class and age. Then it prints it all out, but adjusts the letter grade down by one grade.

Program 10: Pizza. William runs a pizza analysis service. For each pizza, he needs to record the follow:

The name of the company.
The diameter of the pizza.
The weight of the pizza.

Devise a structure that can hold this information and write a program using a structure variable of that type. The program should ask the user to enter each of the items of information listed above, then the program should display the information. Use cin (or its methods) and cout.

---------------

Program 9:
Team. Write a Program that will create an array of structures describing relevant statistics of the members of your favorite sport team (preferably in a sport not out on strike). Read the data about your favorite team member into the first element of your array, and then print out the information. Include an array for the member's three highest scoring totals over the last five years. At the end, include a statement of the amount of memory each array element uses.

-------------

Program 8: Precedence. Write a program using the rules for precedence and associativity and the variables below, which will produce the result for each of the following:

variables: a, b, c                

output should give result for  the multiplication of a times b plus c and a second result for the multiplication of b plus c times a.

----------

    Program 7: Miles:

    Program 6: Height:

    Program 5: Numerics:

    Program 4: Furlongs:

    Program 3: Celsius:

    Program 2. Address

    Program 1. Schedule: