write a program in C++ to convert celcius to farenheit
Answers
using namespace std;
int main()
{
float fahrenheit, celsius;
cout << "Enter the temperature in Celsius : ";
cin >> celsius;
fahrenheit = (celsius * 9.0) / 5.0 + 32;
cout << "The temperature in Celsius : " << celsius << endl;
cout << "The temperature in Fahrenheit : " << fahrenheit << endl;
return 0;
}
HOPE IT HELPS PLZ MARK AS BRAINLIEST
Answer:
hello
Explanation:
model 1
import java.util.*;
class FahrenheittoCelsius
{
double celsius(double f)
{
return (f-32)*5/9;
}
public static void main(String arg[])
{
double a,c;
Scanner sc=new Scanner(System.in);
System.out.println("Enter Fahrenheit temperature");
a=sc.nextDouble();
FahrenheittoCelsius fah=new FahrenheittoCelsius( );
double result=fah.celsius(a);
System.out.println("Celsius temperature is = "+result);
}
}
model 2
import java.util.*;
class FC
{
public static void main(String arg[])
{
double f,c;
Scanner sc=new Scanner(System.in);
System.out.println("Choose type of conversion 1.Fahrenheit to Celsius 2.Celsius to Fahrenheit");
int ch=sc.nextInt();
switch(ch)
{
case 1: System.out.println("Enter Fahrenheit temperature");
f=sc.nextDouble();
c=(f-32)*5/9;
System.out.println("Celsius temperature is = "+c);
break;
case 2: System.out.println("Enter Celsius temperature");
c=sc.nextDouble();
f=((9*c)/5)+32;
System.out.println("Fahrenheit temperature is = "+f);
break;
default: System.out.println("please choose valid choice");
}
}
}
Hope helpful.....