Answer to Question #173857 in C++ for P. Gokul

Question #173857

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


1
Expert's answer
2021-03-21T11:07:48-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS