Program to read temperature in centigrade and display a suitable message according to the temperature state below: 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 Its Hot Temp >=40 then Its Very Hot

Here, we have a basic program example to display a message according to the given temperature using different languages. This program is created in c language, c++, Java, and Python.

Program to display message for the given temperature in C language

#include <stdio.h>
void main()
{
     int tmp;

    printf("Input the temperature : ");
    scanf("%d",&tmp);
   if(tmp<0)
      printf("Freezing weather.\n");
   else if(tmp<10)
      printf("Very cold weather.\n");
   else if(tmp<20)
      printf("Cold weather.\n");
   else if(tmp<30)
      printf("Normal in temp.\n");
   else if(tmp<40)
      printf("Its Hot.\n");
   else
      printf("Its very hot.\n");
}

Program to display message for the given temperature in C++ language

#include<iostream>
using namespace std;
int main()
{
   int tmp;

    cout<<"Input the temperature : ";
    cin>>tmp;
   if(tmp<0)
      cout<<"Freezing weather.\n";
   else if(tmp<10)
      cout<<"Very cold weather.\n";
   else if(tmp<20)
      cout<<"Cold weather.\n";
   else if(tmp<30)
      cout<<"Normal in temp.\n";
   else if(tmp<40)
      cout<<"Its Hot.\n";
   else
      cout<<"Its very hot.\n";
}

Program to display message for the given temperature in Python language

tmp=int(input("Enter the temperature:  "))
if(tmp<0):
    print("Freezing weather.")
elif(tmp<10):
    print("Very cold weather.")
elif(tmp<20):
    print("Cold weather.")
elif(tmp<30):
    print("Normal in temp.")
elif(tmp<40):
    print("Its Hot.")
else:
    print("Its very hot.")

Program to display message for the given temperature in Java language

import java.util.*;
class temperature
 {
   public static void main(String[] args)
    {
       
      int tmp;

      Scanner s=new Scanner(System.in);
      System.out.println("Enter the temperature:");
      tmp = s.nextInt();
      if(tmp<0)
         System.out.println("Freezing weather.");
      else if(tmp<10)
         System.out.println("Very cold weather.");
      else if(tmp<20)
         System.out.println("Cold weather.");
      else if(tmp<30)
         System.out.println("Normal in temp.");
      else if(tmp<40)
         System.out.println("Its Hot.");
      else
        System.out.println("Its very hot.");
}
}