Answer to Question #333566 in C++ for Rille

Question #333566

Build a C++ program to read the temperature in centigrade and display a suitable message according to the temperature state below: (nested-if else/switch case)


Temp <0 then freezing weather


Temp 0-10 then very cold weather


Temp 10-20 then cold weather


Temp 20-30 then normal in Temp


Temp 30-40 then it is hot


Temp >=40 then it is very hot


Example Input: 42


Expected Output: It is very hot.


Give the explanation about this program and how it works?

1
Expert's answer
2022-04-25T15:15:39-0400


#include <iostream>
using namespace std;


int main()
{
  int tem;
  cout<<"Input:";
  cin>>tem;
  if(tem<0)
    cout<<"freezing weather\n";
  else if(tem<10)
    cout<<"very cold weather\n";
  else
    if(tem<20)
      cout<<"cold weather\n";
  else
      if(tem<30)
        cout<<"normal in Temp\n";
  else
        if(tem<40)
          cout<<"it\'s hot\n";
  else 
          cout<<"it\'s very hot\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
APPROVED BY CLIENTS