Absolute zero is the lowest temperature that can be reached; it is -273.15°c, or 0k. The above preogram, even when corrected l, will produce erroneous results when given a temperature below zero, Place a check in the main program that will produce an error if a temperature is given below -273.15°c.
#include <iostream>
using namespace std;
int main()
{
signed long a= -273.15, b;
// prompt user to enter temperature in degree celcius
cout<<"Enter temperature in degree celcius:";
cin>>b;
/* use if condition statement to check if the entered temperature is less that the given temperature*/
if(b<a){
cout<<"Error!!!";
}
else{
cout<<"The temperature is above -273.15";
}
cout<<b;
return 0;
}
Comments
Leave a comment