



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




#include int main() { int temperature; printf("Enter temperature (°C):"); scanf("%d", &temperature); //out of range(invalid range) if(temperature<-50 &&temperature<100){ printf("Error message"); } //heating element activation else if(temperature <10){ printf("activates heating element"); } //normal operation else if(temperature>=10 && temperature <=30){ printf("maintain normal operation") ; } //cooling fan else if(temperature>=31 && temperature<=50) printf("activate the cooling fan"); } //overheat alarm else{ printf("overheat alarm"); } return 0; } pseudocode START INPUT TEMPERATURE If temperature <-50 &&temperature<100 then print("Error message:out of range") If temperature <10 then print("heating element activation") If temperature>=10 && temperature <=30 then print("normal operation") If temperature >=31 && temperature<=50 then print("cooling fan is activated")
print ("over heat alarm triggered ") END (1.2) #include int main() { int temperature; //temperature input printf("Enter temperature (°C):"); scanf("%d", &temperature); //validate temperature range if(temperature<-50 || temperature<100){ printf("Error message"); } //heating element activation else if(temperature <10){ printf("activates heating element"); } //normal operation else if(temperature>=10 && temperature <=30){ printf("maintain nornal operation") ; } //cooling fan else if(temperature >=31 && temperature<=50){ printf("activate the cooling fan"); } //overheat alarm else{ printf("overheat alarm"); } return 0; } (1.3) START Input temperature Input temperature // Validate temperature1 and temperature IF (temperature1 < -50 OR temperature1 > 100) OR (temperature2 < -50 OR temperature2 > 100) then
// Input temperatures printf("Enter temperature for Zone 1: "); scanf("%f", &temperature1); printf("Enter temperature for Zone 2: "); scanf("%f", &temperature2); // Validate temperature1 amd temperature if ((temperature1 < -50 || temperature1 > 100) || (temperature2 < -50 || temperature2 > 100)) { printf("Error: One or both temperatures out of valid range\n"); } // If temperature1 equals temperature 2 else if (temperature1 == temperature2) { if (temperature1 < 10) { printf("Heating element activated (Both Zones)\n"); } else if (temperature1 <= 30) { printf("System in normal operation (Both Zones)\n"); } else if (temperature1 <= 50) { printf("Cooling fan is activated (Both Zones)\n"); } else { printf("over heat alarm id triggered (Both Zones)\n"); } } // If temperatures are different else { // Zone 1 if (temperature1 < 10) { printf("Zone 1: Heating element activated#include int main() { int temperature1 , temperature2; // Input temperatures printf("Enter temperature for Zone 1: "); scanf("%f", &temperature1); printf("Enter temperature for Zone 2: "); scanf("%f", &temperature2); // Validate temperature1 amd temperature if ((temperature1 < -50 || temperature1 > 100) || (temperature2 < -50 ||
temperature2 > 100)) { printf("Error: One or both temperatures out of valid range\n"); } // If temperature1 equals temperature 2 else if (temperature1 == temperature2) { if (temperature1 < 10) { printf("Heating element activated (Both Zones)\n"); } else if (temperature1 <= 30) { printf("System in normal operation (Both Zones)\n"); } else if (temperature1 <= 50) { printf("Cooling fan is activated (Both Zones)\n"); } else { printf("over heat alarm id triggered (Both Zones)\n"); } } // If temperatures are different else { // Zone 1 if (temperature1 < 10) { printf("Zone 1: Heating element activated\n"); } else if (temperature1 <= 30) { printf("Zone 1: NORMAL operation\n"); } else if (temperature1 <= 50) { printf("Zone 1: Cooling fan activated\n"); } else { printf("Zone 1: overheat alarm triggered\n"); } // Zone 2 if (temperature2 < 10) { printf("Zone 2: Heating element activated\n"); } else if (temperature2 <= 30) { printf("Zone 2: NORMAL operation\n"); } else if (temperature2 <= 50) { printf("Zone 2: Cooling fan activated\n"); } else { printf("Zone 2: overheat alarm triggered\n");