Pages

Sunday, June 25, 2017

Fahrenheit to Celsius using C++

Write C++ program to read temperature in Fahrenheit and print it in Celsius.

#include<iostream>
using namespace std;

int main()
{
  float f,c;
  cout << "Enter temperature in Fahrenheit(f)=";
  cin >> f;

  c = 5 * ( f - 32 ) / 9;

  cout<<"Temperature in Celsius = " << c;

  return 0;
}

Output of program

Enter temperature in Fahrenheit(f)=100
Temperature in Celsius = 37.7778

No comments:

Post a Comment