This C program analyzes water temperature samples provided in Kelvin, converting them to Celsius and Fahrenheit, determining the state of the sample (solid, liquid, or gas), and calculating useful statistics like maximum, minimum, average temperature, and number of values below a threshold.
- Accepts 10 temperature values in Kelvin
- Converts temperatures to:
- Celsius
- Fahrenheit
- Determines the physical state of water at each temperature
- Finds:
- Maximum temperature
- Minimum temperature
- Average temperature
- Count of samples below a threshold temperature
- Solid: Temperature in Celsius is ≤ 0°C
- Liquid: Temperature in Celsius is > 0°C and < 100°C
- Gas: Temperature in Celsius is ≥ 100°C
| Function | Description |
|---|---|
kelvinToCelsius() |
Converts Kelvin to Celsius |
celsiusToFahrenheit() |
Converts Celsius to Fahrenheit |
determineState() |
Determines if the temperature represents Solid, Liquid, or Gas |
findMax() |
Returns the maximum value in an array |
findMin() |
Returns the minimum value in an array |
calculateAverage() |
Computes average of all values in an array |
countBelowThreshold() |
Counts how many temperatures are below a given threshold |
displayResults() |
Prints Kelvin, Celsius, Fahrenheit, and state in a table |
Enter temperature in Kelvin: 273
Enter temperature in Kelvin: 310
...
Enter the threshold temperature in Kelvin: 295
Kelvin Celsius Fahrenheit State
273.00 -0.15 31.73 Solid
310.00 36.85 98.33 Liquid
...
Max temperature: 310.00 K
Min temperature: 273.00 K
Average temperature: 291.50 K
Number of samples below 295.00 K: 5
Use any C compiler such as GCC:
gcc main.c functions.c -o temperatureAnalyzer
./temperatureAnalyzerMake sure all relevant functions are implemented either in the same file or modularly with headers.
project/
├── main.c // Main function and logic
├── functions.c // Function definitions
├── temperature.h // Function declarations
├── README.md // Project overview (this file)
├── Pseudocode.pdf // Pseudocode representation
├── Structure_chart.jpg // Project structure chart
├── test_cases.pdf // Defined test cases
Ahmed Ali