Analyze Temperature Array

CCBeginner
Practice Now

Introduction

In this challenge, a junior meteorologist will process daily temperature readings to gain insights into local weather patterns using C programming array manipulation skills. The goal is to declare an integer array to store 6 daily temperature readings, calculate the average temperature, find and store the highest and lowest temperatures, and print out the results with clear, descriptive labels.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL c(("C")) -.-> c/ControlFlowGroup(["Control Flow"]) c(("C")) -.-> c/CompoundTypesGroup(["Compound Types"]) c(("C")) -.-> c/UserInteractionGroup(["User Interaction"]) c/ControlFlowGroup -.-> c/for_loop("For Loop") c/CompoundTypesGroup -.-> c/arrays("Arrays") c/UserInteractionGroup -.-> c/output("Output") subgraph Lab Skills c/for_loop -.-> lab-438390{{"Analyze Temperature Array"}} c/arrays -.-> lab-438390{{"Analyze Temperature Array"}} c/output -.-> lab-438390{{"Analyze Temperature Array"}} end

Analyze Temperature Array

As a junior meteorologist, you'll process daily temperature readings to gain insights into local weather patterns using C programming array manipulation skills.

Tasks

  • Declare an integer array to store 6 daily temperature readings
  • Calculate the average temperature
  • Find and store the highest temperature
  • Find and store the lowest temperature
  • Print out the average, highest, and lowest temperatures

Requirements

  • Create the solution in the file ~/project/temperature_analysis.c
  • Use an integer array to store 6 temperature values
  • Temperatures should be stored in the order: 72, 68, 75, 80, 65, 78
  • Calculate the average temperature using a floating-point calculation
  • Print the results with clear, descriptive labels
  • Use a single for loop to process the array efficiently

Examples

Complile and run the program to display the average, highest, and lowest temperatures.

gcc temperature_analysis.c -o temperature_analysis
./temperature_analysis

Example output:

Average Temperature: 73.0 degrees
Highest Temperature: 80 degrees
Lowest Temperature: 65 degrees

Hints

  • Use a single for loop to calculate total and find max/min.
  • Convert integer total to float for average calculation, such as float average = (float)total / 6.
  • Initialize max and min with the first array element.
  • Use comparison operators to track highest and lowest temperatures.
โœจ Check Solution and Practice

Summary

In summary, this challenge requires the junior meteorologist to use C programming skills to process an array of daily temperature readings. The tasks include declaring an integer array to store 6 temperature values, calculating the average temperature, finding and storing the highest and lowest temperatures, and printing the results with clear labels.