Fahrenheit to celsius program

farenheit to celsius in c

#include<stdio.h>
#include<conio.h>
float CalculateCelsius(float farenheit);
void main()
{
	float farenheit;
	printf("Enter the temp of farenheit \n");
	scanf("%f",&farenheit);
	float celsius=CalculateCelsius(farenheit);
	printf("Temperature in Celsius %2f",celsius);
	getch();
}
float CalculateCelsius(float farenheit)
{
	float celsius=((5*farenheit)-160)/9;
	return celsius;
}

Output

Enter the temp of farenheit
11.23
Temperature in Celsius -11.538889

farenheit to celsius in c++

#include<iostream>
#include<conio.h>
using namespace std;
class ConvertFarenheitToCelsius
{
public:
	float CalculateCelsius(float farenheit)
    {
	 float celsius=((5*farenheit)-160)/9;
	 return celsius;
    }
};
void main()
{
	float farenheit;
	cout<<"Enter the temp of farenheit \n";
	cin>>farenheit;
	ConvertFarenheitToCelsius obj;
	float celsius=obj.CalculateCelsius(farenheit);
	cout<<"Temperature in Celsius "<<celsius;
	getch();
}

Output

Enter the temp of farenheit
68
Temperature in Celsius 20

farenheit to celsius in c#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConvertFarenheitToCelsiusProject
{
    class ConvertFarenheitToCelsius
    {
        public double CalculateCelsius(double farenheit)
        {
            return ((5 * farenheit) - 160) / 9;
        }
        static void Main(string[] args)
        {
            ConvertFarenheitToCelsius obj = new ConvertFarenheitToCelsius();
            Console.WriteLine("Enter the temp of farenheit ");
            double farenheit = Convert.ToDouble(Console.ReadLine());
            double celsius = obj.CalculateCelsius(farenheit);
            Console.WriteLine("Temperature is Celsius "+celsius);
            Console.ReadLine();
        }
    }
}

Output

Enter the temp of farenheit
45
Temperature is Celsius 7.22222222222222

farenheit to celsius in java

import java.util.*;
class ConvertFarenheitToCelsius
{
	public float CalculateCelsius(float farenheit)
    {
        return ((5 * farenheit) - 160) / 9;
    }
}
class examples
{
public static void main(String[] args)
	{
	ConvertFarenheitToCelsius obj=new ConvertFarenheitToCelsius();
	Scanner sc=new Scanner(System.in);
	System.out.println("Enter the temp of farenheit");
	float farenheit=sc.nextFloat();
	float celsius=obj.CalculateCelsius(farenheit);
	System.out.println("Temperature in celsius "+celsius);
	}
}

Output

Enter the temp of farenheit
86
Temperature in celsius 30.0

Write a comment


Name Email Message