205k views
2 votes
Write a flowchart and program that does the following: Asks the user for the average temperature in each of the last 12 months After the user has entered the temperatures, the program should display them Uses a "for" loop to ask for the data, and use another "for" loop to display the data Stores the data in an array called "temperature"

User Enock
by
7.7k points

1 Answer

4 votes

Answer:

Written in C++

#include<iostream>

using namespace std;

int main(){

float temperature[12];

for(int i =0; i<12;i++){

cout<<"Temperature "<<1 + i<<": ";

cin>>temperature[i];

}

for(int i =0; i<12;i++){

cout<<"Temperature "<<1 + i<<": "<<temperature[i]<<endl;

}

return 0;

}

Step-by-step explanation:

This line declares temperature as an array of 12 elements

float temperature[12];

The following loop prompts user for (and gets) input of temperature in the last 12 months

for(int i =0; i<12;i++){

cout<<"Temperature "<<1 + i<<": ";

cin>>temperature[i];

}

The following loop prints the input data

for(int i =0; i<12;i++){

cout<<"Temperature "<<1 + i<<": "<<temperature[i]<<endl;

}

See Attachment for flowchart

Write a flowchart and program that does the following: Asks the user for the average-example-1
User Giles Roberts
by
7.2k points