Calculate Fahrenheit temperature and output - C++ File Stream

C++ examples for File Stream:cin

Description

Calculate Fahrenheit temperature and output

Demo Code

#include <iostream>
using namespace std;
int main()// w w  w. ja va 2 s  .c o  m
{
   double ctemp;   // Celsius temperature
   double ftemp;   // Fahrenheit temperature
   // Get value of ctemp (Celsius temp).
   cout << "Input a Celsius temp and press ENTER: ";
   cin >> ctemp;
   // Calculate ftemp (Fahrenheit temp) and output.
   ftemp = (ctemp * 1.8) + 32;
   cout << "Fahrenheit temp is: " << ftemp << endl;
   return 0;
}

Result


Related Tutorials