fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // Desired temperature range
  6. const int MIN_TEMP = 2; // Minimum safe temperature in °C
  7. const int MAX_TEMP = 8; // Maximum safe temperature in °C
  8.  
  9. int currentTemp;
  10.  
  11. cout << "Enter current refrigerator temperature (°C): ";
  12. cin >> currentTemp;
  13.  
  14. // Check temperature against limits
  15. if (currentTemp < MIN_TEMP) {
  16. cout << "ALERT: Temperature too LOW! Risk of freezing food." << endl;
  17. }
  18. else if (currentTemp > MAX_TEMP) {
  19. cout << "ALERT: Temperature too HIGH! Risk of spoiling food." << endl;
  20. }
  21. else {
  22. cout << "Temperature is within safe range. Food is preserved." << endl;
  23. }
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5320KB
stdin
34
stdout
Enter current refrigerator temperature (°C): ALERT: Temperature too HIGH! Risk of spoiling food.