Question

Hi quick question can you solve this for me cause I'm a little bit confuse about...

Hi quick question can you solve this for me cause I'm a little bit confuse about this one thanks! this is c++ and yes I'll give you a thumbs up thank you ^^

Write a program that reads in temperatures. Use a while loop (or a do..while loop, if you prefer, but the while loop might be easier). When the user enters -999, the loop exits. Then, print out the average temperature, the highest and the lowest temperature entered.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

PROGRAM

OUTPUT

#include <iostream>
using namespace std;
int main()
{
    float temp[100], max, min, average,sum=0;
    int n,i;
    cout<<"Enter the temperatures in fahrenheit\n";
    i=0;
    do
     {
       cin>>temp[i];
        i=i+1;
    }while (temp[i-1] != (-999));
   n=i;
    for (i=0; i<n; i++)
    {
        sum = sum+ temp[i];
    }
    average = sum/n;
    cout<<"\nThe average temperature is: "<<average;
    max=temp[0];
    for (i=1;i<n;i++)
    {
        if (max < temp[i])
        max = temp[i];
       
    }
    cout<<"\nThe highest temperature is: "<<max;
    min= temp[0];
    for (i=1;i<n;i++)
    {
       if (min> temp[i])
        min= temp [i];
    }
    cout<<"\nThe lowest temperature is: "<<min;
   
  
}

I hope this is what you are looking for.. Please rate this answer to let me know it was helpful to you.. Thanks for reading..

Add a comment
Know the answer?
Add Answer to:
Hi quick question can you solve this for me cause I'm a little bit confuse about...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT