Figured it out.

int temp=0;
for (int i = 1; i < num_days; i++ )
    {
    temp=temperature[i]+temp; // assuming temperature array is int
    }
float ans=temp/num_days;
return ans;

I figured it out. Thanks.

I figured it out. Thanks.

Next time, just leave your original post as is so that someone else can benefit from it if it applies to their problem. By "deleting" your original post, you've made this thread completely worthless to future readers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.