Does anyone know what's wrong with this function? The program that uses it runs but does not display the average. I also tried using the sum variable instead of ptr3 and had the same results.
void calculate(int days)
{
float sum = 0;
float average;
temperature_node *ptr2;
temperature_node *ptr3;
ptr2 = new temperature_node;
ptr3 = new temperature_node;
current_ptr = head_ptr;
ptr2 = current_ptr->next;
do
{
ptr3->temperature = current_ptr->temperature + ptr2->temperature;
current_ptr = ptr2->next;
}while(ptr2 != NULL);
cout << ptr3->temperature;
average = ptr3->temperature / days;
cout << average;
}