Question

Question 7 10 points Save Write a Matlab or C program to store 12 temperature values in a day like per hour in°C in an array
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the completed code for this problem in C language. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. If not, PLEASE let me know before you rate, I’ll help you fix whatever issues. Thanks

#include<stdio.h>

int main(){

                const int size=12;

                //defining a float array of size 12

                float temp[size];

                //asking and reading 12 temperature values from keyboard to temp array

                printf("Enter 12 temperature values: ");

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

                                scanf("%f",&temp[i]);

                }

                //initializing sum to 0

                float sum=0;

               

                printf("Temperatures:\n");

                //looping through each element

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

                                //printing temperature with a precision of 1 digit after decimal point

                                printf("%.1f C\n",temp[i]);

                                //adding to sum

                                sum+=temp[i];

                }

                //finding and printing average.

                float avg=(float)sum/size;

                printf("\nAverage temperature is %.1f C\n",avg);

                return 0;

}

/*OUTPUT*/

Enter 12 temperature values: 22.4 24 28.2 26.5 23.7 30 31 29.4 28.4 27.3 28 29

Temperatures:

22.4 C

24.0 C

28.2 C

26.5 C

23.7 C

30.0 C

31.0 C

29.4 C

28.4 C

27.3 C

28.0 C

29.0 C

Average temperature is 27.3 C

Add a comment
Know the answer?
Add Answer to:
Question 7 10 points Save Write a Matlab or C program to store 12 temperature values...
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
  • Write a MATLAB program to do the following: Receive 5 input values and store them into...

    Write a MATLAB program to do the following: Receive 5 input values and store them into a single 1x5 array Receive another 2 input values and store them into a separate 1x2 array Add the scalar value 5 to each array value Store each array into 2 cells within one cell array Also store each array as separate elements within one struct

  • Structures in C++ :- 2. Write a program that declares a structure to store the distance...

    Structures in C++ :- 2. Write a program that declares a structure to store the distance covered by player along with the time taken to cover the distance. The program should input the records of two players and then display the record of the winner. 3. Write a program that declares a structure to store income, tax rate and tax of a person. The program defines an array of structure to store the records of five person. It inputs income...

  • Write a C program Design a program that uses an array to store 10 randomly generated...

    Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...

  • Structures in C++ :- 1. Write a program that declares a structure to store the code...

    Structures in C++ :- 1. Write a program that declares a structure to store the code number, salary and grade of an employee. The program defines two structure variables, inputs record of two employees and then displays the record of the employee with more salary. 2. Write a program that declares a structure to store the distance covered by player along with the time taken to cover the distance. The program should input the records of two players and then...

  • 29. (20 points) Write the complete C++ program that implements the following program, as if you...

    29. (20 points) Write the complete C++ program that implements the following program, as if you were turning this in for homework. Your program should have a commented header (your name, etc), comments within the program and a well-built display for the output. Don't forget the pre-processor commands Define an array called nums with a maximum of 20 integers, and fill the array with numbers, recei the keyboard (prompt for the numbers.) In this program, exactly 20 integers will be...

  • (C++) Write a program that declares a struct to store the data of a football player...

    (C++) Write a program that declares a struct to store the data of a football player (player’s name, player’s position, number of touchdowns, number of catches, number of passing yards, number of receiving yards, and the number of rushing yards). Declare an array of 10 components to store the data of 10 football players. Your program must contain a function to input data and a function to output data. Add functions to search the array to find the index of...

  • The answer need to write in C programming. QUESTION 2 Write a program using array to...

    The answer need to write in C programming. QUESTION 2 Write a program using array to generate a multiplication table based on the user's input. For example if user enter 5 as input then a multiply table for 1 to 5 is printed as output as shown in Figure Q2. There are three main steps in this program which are: Print rows (a) (b) Print columns Print multiplication of data inside table (c) Select C:\example1 \bin\Debuglexample 1.exe enter the value...

  • Python 3 coding with AWS/IDLE. DDI&T a Python program to input, store, and process hourly temperatures for each hour...

    Python 3 coding with AWS/IDLE. DDI&T a Python program to input, store, and process hourly temperatures for each hour of the day (i.e., 24 temperatures). Your program should be divided logically into the following parts: In function main() declare an empty List container:          HourlyTemperatures = []     Pass the empty HourlyTemperatures list to a function, GetTemperatures(HourlyTemperatures)          This function must interactively prompt for and input temperatures for each of the 24 hours in a day (0 through 23). For each temperature that...

  • C Program Question 1: Write a program that reads a date from the keyboard and tests...

    C Program Question 1: Write a program that reads a date from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is not valid. The input date will have the format: mm/dd/yyyy Note that there is no space in the above format. A date in this format must be entered in one line. A valid...

  • Write in coral please QUESTION 7 5 points Save Answer Complete the program below to convert...

    Write in coral please QUESTION 7 5 points Save Answer Complete the program below to convert water temperatures from degrees Celsius to degrees Fahrenheit. Then, warn the swimmers if the water temperature is too cold or too hot. If the water temperature is 77 degrees Fahrenheit or less, it is too cold to swim. If the water is 104 degrees Fahrenheit or more, it is too hot to swim. Example 1: input: 55 output: Water temperature is 131.0 degrees Fahrenheit....

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
ADVERTISEMENT