Question
1. Define an int const named NUM_EXPENSES and set it to 7. 2. Define an array named expenses of seven double values with these initial
1. Define an int const named NUM_EXPENSES and set it to 7.
2. Define an array named expenses of seven double values with these initial values: 45.25, 49.38, 12.75, 123.50, 8.25, 19.95 and 145.70.
3. Define and initialize a pointer named ptr that can point to a double.
4. Iterate through the array using ptr to calculate the total and average of the expenses.
5. Reporting. Write a block of code to print a report. The block of code should print the report header first. Then use the pointer variable to iterate through the expenses array to print the expenses. Finally print the total and the average. The output should look exactly as follows (single space).
# Amount ---------------------- 1 45.25 2 49.38 3 12.75 4 123.50 5 8.25 6 19.95 7 145.70 Total 404.78 Average 57.83
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started