Program name:-write a c++ program to convert celsius to fahrenheit and vice versa.

Sourcee code –
#include<iostream>
using namespace std;
float celsius_To_Fahrenheit(float celsius);
float fahrenheit_To_celsius(float fahrenheit);
int main(){
float celsius,fahrenheit,celsi,entered_fahrenheit;
cout<<“Enter celcius to convert to fahrenheit “;
cin>>celsius;
fahrenheit=celsius_To_Fahrenheit(celsius);
cout<<fahrenheit;
cout<<“nEnter fahrenheit to convert to celsius “;
cin>>entered_fahrenheit;
celsi=fahrenheit_To_celsius(fahrenheit);
cout<<celsi;
}
float celsius_To_Fahrenheit(float celsius){
float fahrenheit;
//T(°F) = 20°C × 9/5 + 32 = 68 °F
fahrenheit=((celsius*9)/5)+32;
return fahrenheit;
}
float fahrenheit_To_celsius(float entered_fahrenheit){
float celsi;
//T(°C) = (68°F – 32) × 5/9 = 20 °C
celsi=((entered_fahrenheit-32)*5)/9;
return celsi;
}
OUTPUT-
Enter celcius to convert to fahrenheit 20
68
Enter fahrenheit to convert to celsius 68
20

Leave a Comment

Your email address will not be published. Required fields are marked *

Hire a server Expert to resolve the issue Now.

Hire a server Expert to resolve the issue Now.

Resolve this issue in just 5$ from https://serverexpert.io

 

You have Successfully Subscribed!

Open chat