Professional Documents
Culture Documents
NRP : 4122600044
Kelas : 2 D4 Mekatronika B
Code :
#include <stdio.h>
int main() {
float temperatures[7];
int consecutiveHotDays = 0;
// Data Input
do {
scanf("%f", &temperatures[i]);
printf("Invalid temperature. Please enter a valid temperature between -45°C and 65°C.\n");
// Initialize hottestTemp and coldestTemp with the temperature of the first day
hottestDay = coldestDay = 1;
// Data Analysis
hottestTemp = temperatures[i];
hottestDay = i + 1;
coldestDay = i + 1;
consecutiveHotDays++;
if (consecutiveHotDays >= 3) {
printf("Heatwave detected!\n");
} else {
consecutiveHotDays = 0;
averageTemp = 0;
averageTemp += temperatures[i];
averageTemp /= 7;
// Output
if (consecutiveHotDays < 3) {
return 0;