This is my code so far. The code works properly until the highlighted section. It has to be in C++ not C.
#include <stdio.h>
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
const int array_size = 32;
int daily_temp[array_size];
int num_values;
int index;
float average_high;
int total = 0;
int min;
int max;
do
{
cout<< "Enter the number of days for which you have data: ";
cin>>num_values;
if((num_values<1)||(num_values > array_size-1))
{
cout<< "The number of days must be in the range 1 to "
<< array_size-1<<endl;
}
}while((num_values<1)||(num_values > array_size-1));
for(index = 1; index<= num_values; index++)
{
cout<<"Enter the high temperature for day "<<index<< ": ";
cin>>daily_temp[index];
}
cout<< "The array contains high temperatures for " << num_values
<<" days.\n";
cout<< "The values are as follows.\n";
for(index = 1; index<= num_values; index++)
{
cout<< "Day "<< index<< ": "<< daily_temp[index]<<endl;
total=total+daily_temp[index];
}
average_high= float(total)/ float(num_values);
cout<<"The average high temperature during the "<<num_values
<<"-day period was "<< setprecision(2)<< average_high
<<" degrees.\n";
max = daily_temp[index];
for (index = 0; index < num_values; index++)
{
if (max < daily_temp[index])
max = daily_temp[index];
}
min = daily_temp[index];
for (index = 0; index < num_values; index++)
{
if (min > daily_temp[index])
min = daily_temp[index];
}
cout << "Largest element: " << max <<endl;
cout << "Smallest element: " << min <<endl;
return 0;
}