Answer to Question #193097 in C++ for Sarivinkumar M

Question #193097

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-05-13T13:52:49-0400
#include <iostream>

int main()
{
    int T;
    std::cout << "Enter the temperature: ";
    std::cin >> T;

    if(!std::cin)
    {
        std::cout << "Error: invalid data\n";
    }
    else
    {
        if(T <= 0) 
            std::cout << "Its very very cold";
        else if(0 < T && T <= 10)
            std::cout << "Its cold";
        else if(10 < T && T <= 20)
            std::cout << "Its cool out";
        else if(20 < T && T <= 30)
            std::cout << "Its warm";
        else
            std::cout << "Its hot";

        std::cout << "\n";
    }
    
    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