Sample output
Enter an index >
5
The letter at index 5 is
f
Enter an index >
8
The letter at index 8 is
i
Enter an index >
21
The letter at index 21 is
v
Enter an index >
90
Invalid index.
Exiting.
double average(double temps[],
int size) //returns average of array
void
minmax(double temps[], int size,
double& max, double& min)
//assign the min and max values in the array to min and max
In the main, declare a 7-element array
of type double denoting temperature values for a full week. The
program should fill the array via user input, then call average and
minmax to calculate the average, min, and max values. In the main,
print the result.
Sample output
Enter temperature values for
the week > 35.5 40 37.8 42 45 41.3 42.4
The average temperature is
40.5714
The min was 35.5 and the max
was 45
void
FillProfit(int profit[], int&
daysOpen) //asks the user how many days they should open, then
fills the profit values for the number of days
int
TotalProfit(int profit[], int
daysOpen) //returns the sum of the filled elements
Declare an integer MAX_OPEN_DAYS and
initialize it to 7. In the main, declare an integer array of size
MAX_OPEN_DAYS, then call FillProfit to fill it, and TotalProfile to
calcualte the total profit. Print the total in the main.
Sample output
How many days did you open the
shop this week? 4
Enter the profit for 4 days
> 388 902 1003 239
The total profit for this week
was 2532
Sample output Enter an index > 5 The letter at index 5 is f Enter an index > 8 The letter at index 8 is i Enter an index
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am