Develop a C++ program to get the temperature and print the following status according to the given temperature by using else if ladder statement.
1. T<=0 "Its very very cold"
2. 0 < T <=10 "Its cold"
3. 10 < T < =20 "Its cool out"
4. 20 < T < =30 "Its warm"
5. T>30 "Its hot
#include <iostream>
using namespace std;
//The start point of the program
int main (){
float T;
//get the temperature and print the following status according to the given temperature by using else if ladder statement.
cout<<"Enter the temperature: ";
cin>>T;
//1.0 T<=0 "Its very very cold"
//2. 0 < T <=10 "Its cold"
//3. 10 < T < =20 "Its cool out"
//4. 20 < T < =30 "Its warm"
//5. T>30 "Its hot
if(T<=0){
cout<<"\nIts very very cold\n";
}
if(T>0 && T<=10){
cout<<"\nIts cold\n";
}
if(T>10 && T<=20){
cout<<"\nIts cool out\n";
}
if(T>20 && T<=30){
cout<<"\nIts warm\n";
}
if(T>30){
cout<<"\nIts hot55\n";
}
//delay
system("pause");
return 0;
}
Comments
Leave a comment