CS211 Programming I for Engineers Professor Ziegler 40 points (out of 200

)
Write a C program as follows: (note that an initial block comment and flow charts are not required). However, all other good programming procedures including indenting, comments, bracket alignment, etc. must be utilized.

Begin with your own Lab 8. Modify the lab so that the function you wrote to print the accounts meets the following requirements: #1 RULE: You must use pointers to reference any variables passed into the print function that will be described later. If you use indexing via non-pointers (ie. [x]), then your grade for take-home portion of the exam will be zero (out of 40) regardless of any other work you completed for the exam. MAIN: 1. Create the supporting code necessary to call the print function which will consist of 3 parameters, all passed by reference using pointers: a. The array that holds all of the account information b. The number of rows in the array c. The number of columns the array 2. You must use pointers to reference all of the variables passed into the print function FUNCTION: 1. The function will receive at least three parameters as described above. These 3 parameters must be passed by reference using pointers. 2. The function must work for ANY size array, not just 10 x 3. However, you may pass in the exact array dimensions from main. 3. All requirements for the print function from Lab 8 must still be met. 4. Be sure to print the array of records in rows by customer (just as in the original Lab 8) 5. HINT: I used a FOR loop to traverse the pointer through the array and had to modify the counter (i) to end the loop – In other words, I had to do more to the variable “i” than just increment by one. 6. Because you are using a Pointer to navigate through the array of records, you will not be able to print a row of data as easy as you did when using indexing because the pointer does not know where a row begins or ends. I used remainder divide of a counter (to count where I am in the array) by the number of columns - it is time for a new row when the counter is divisible by the number of columns in the original array. HINT: Don’t just divide by 3 – remember that your print function must work for any size array. 7. Because you are using a pointer to navigate through the array of records, you will run into a problem when printing the account number because it must appear as an integer, as opposed to savings and checking which should appear as floats, because the pointer does not know where the first column of each row is located. I used the technique described above to know when the pointer was at the first element of each row and printed that element as an integer (actually as a float with 0 digits to the right of the decimal point).

just as it did for the original Lab 8. for the sake of time. In other words. print. Submit this assignment with all of the functionality of the original Lab 8 in addition to the changes outlined here. Your output should appear as shown in the sample run below: P. the program you submit must be able to add.8. you do not have to resolve this particular situation.O . and exit. My program stops printing the array whenever it finds an element = 0. delete. deposit.T. However. withdraw. This does not work well because the program ceases printing when an existing customer has a checking or savings balance = 0. even though there may be additional customers further into the array. 9. 10.

grade is –50%.add. good variable names. and exit. 10% print the account number without a decimal point 5. even though there may be additional customers further into the array. comments. the grade for this portion of the test will be 0 out of 40. Only pointers can be used to access the arrays in this assignment! No box indexing [ ] is permitted). for the sake of time. 8. 10% Your output should appear as shown in the sample run below. grade is zero.all parameters passed by reference using pointers: a. MAIN: 1. withdraw. The number of columns the array 2. Check with your lab assistant for instructions on how he wishes you to hand in this portion of your test. 10% print the array of records in rows by customer 4. . The number of columns the array FUNCTION: 1. The array that holds all of the account information b.program stops printing the array whenever it finds an element = 0. delete. print. 10% Formatting. this is 100%) If pointers are not used the grade is 0) Call the print function . 10% all of the functionality of the original Lab 8 in addition to the changes outlined here . 7. However. not just 10 x 3 3. 10% (actually. 10% Must work for ANY size array. Do not be concerned with warnings produced by the compiler. brackets line up. The number of rows in the array f. The number of rows in the array c. deposit.  Submit as Instructed: Due: In Lab the last week of classes NOTE REVISED LATE PENALTY: Up to 3 hours late. This does not work well because the program ceases printing when an existing customer has a checking or savings balance = 0. Initial block comment and flow charts are not required. After 3 hours late. this is 100%) d. 10% all parameters passed by reference using pointers: (actually. If box indexing is used. No penalty: . 10% print savings and checking with 2 digits to the right of the decimal point 6. you do not have to resolve this particular situation. 10% Supporting code necessary to call the print function 3. etc 2.Grading: POINTS = 40 100%. The array that holds all of the account information e.

Sign up to vote on this title
UsefulNot useful