Chapter 5:
Conditional Structures
Programming Exercise
Problem # 10:
Write a program that inputs temperature and displays a message as follows:
Temperature Message
Greater than 35 Hot day
Between 25 and 35 (inclusive) Pleasant day
Less than 25 Cool day
Solution:
#include<iostream>
#include<conio.h>
using namespace std;
int main ()
{
float T;
cout<<"Enter temperature:";
cin>>T;
if(T>35)
cout<<"Hot day.";
else if(T>=25)
cout<<"Pleasant day.";
else
cout<<"Cool day.";
return 0;
}
#include<conio.h>
using namespace std;
int main ()
{
float T;
cout<<"Enter temperature:";
cin>>T;
if(T>35)
cout<<"Hot day.";
else if(T>=25)
cout<<"Pleasant day.";
else
cout<<"Cool day.";
return 0;
}
Let me know in the comment section if you have any question.
Previous Post:
9. Program that inputs a year and display "Leap year" if it is a leap year otherwise displays "Not a leap year".
Comments
Post a Comment