18.0k views
4 votes
Write a program that asks the user to enter ten temperatures and then finds the sum. The input temperatures should allow for decimal values. Sample Run Enter Temperature: 27.6 Enter Temperature: 29.5 Enter Temperature: 35 Enter Temperature: 45.5 Enter Temperature: 54 Enter Temperature: 64.4 Enter Temperature: 69 Enter Temperature: 68 Enter Temperature: 61.3 Enter Temperature: 50 Sum = 504.3

User Nickrak
by
4.2k points

1 Answer

1 vote

Answer:

#include <iostream>

#include <conio.h>

using namespace std;

main()

{

float temp[10], sum;

sum=0;

for (int i=1 ; i<= 10; i++)

{

cout<<"Enter the temperature in Decimal for temp"<<i<<"=";

cin>>temp[i];

}

for (int j=1 ; j<=10 ; j++)

{

sum = sum+temp[i];

}

cout<< "/nThe Total Temperature ="<<sum;

getch();

}

Step-by-step explanation:

In this program we can take values of temperature in decimal values by taking the data type of temp variable as float. Array is used to enter the ten temperature values. Sum variable is used to add all the values.

User Cjueden
by
3.7k points