Write a program and draw a flow chart and Algorithm for calculating the average
ID: 3637891 • Letter: W
Question
Write a program and draw a flow chart and Algorithm for calculating the average temperature, given a set of temperature readings such as:78, 85, 87, 90, 92, 94, and 97.
Your program should take any temperature readings, the above set of temperature readings was an example.
Do both parts a, and b below:
a) Assume you don’t know the number of temperature readings. In this case you should use While/While End Loop with a trip value to end the loop.
b) Assume you know there are exactly 7 temperature readings. Use Automatic Loop counter.
Explanation / Answer
a)
#include<iostream>
using namespace std;
int main()
{
int a;
cout<< " enter temperatrue " ;
cin >> a ;
while(a!=-1)
{
cout<< " enter temperatrue -1 to end" ;
cin >> a ;
}
}
#include<iostream>
using namespace std;
int main()
{
int a;
cout<< " enter temperatrue " ;
cin >> a ;
for(int i=0; i<7; i++)
{
cout<< " enter temperatrue -1 to end" ;
cin >> a ;
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.