Write an if-else statement that outputs the word Warning provided that either the value of the variable temperature is greater than or equal to 100, or the value of the variable pressure is greater than or equal to 200, or both. Otherwise, the if-else statement outputs the word OK. The variables temperature and pressure are both of type int.
The following if-else statement that outputs the word 'Warning' provided that either the value of the variable temperature is greater than or equal to 100, or the value of the variable pressure is greater than or equal to 200, or both. Otherwise, the if-else statement outputs the word 'OK':
if ((temperature >= 100) || (preasure >= 200))
cout << "Warning";
else
cout <<"OK";
Complete executable program code:
#include <iostream>
using namespace std;
int main ()
{
//Declare the variables temperature and
//pressure are both of data type int.
int temperature;
int preasure;
//Read temperature value
cout << "Enter a temperature value: ";
cin >>temperature;
//Read preasure value
cout << "Enter a preasure value: ";
cin >>preasure;
//Use if-else statement that outputs the word Warning
//provided that either the value of the variable 'temperature'
//is greater than or equal to 100, or the value of the variable
//'pressure' is greater than or equal to 200, or both. Otherwise,
//the if-else statement outputs the word 'OK'
if ((temperature >= 100) || (preasure >= 200))
cout << "Warning";
else
cout <<"OK";
return 0;
}
Outputs:
Output 1:
Enter a temperature value: 100
Enter a preasure value: 200
Warning
Output 2:
Enter a temperature value: 55
Enter a preasure value: 45
OK