Programming Challenge Chapter 3 – Q #10 Celsius to Fahrenheit – Tony Gaddis – Starting Out With C++

Programming Challenge Chapter 3 – Q #10 Celsius to Fahrenheit – Tony Gaddis – Starting Out With C++










Problem: -

Write a program that converts Celsius temperatures to Fahrenheit temperatures. The formula is
                                      F = 9/5 C + 32
F is the Fahrenheit temperature and C is the Celsius temperature.

Solution: -

#include <iostream>

using namespace std;

int main()

{

      float c;

      float f;

 

      cout << "Enter Temprature in Celsius:";

      cin >> c;

 

      f = (c * 9 / 5) + 32;  //Using Formula F = 9 / 5 * C +32

 

      cout << c << "C into Fahrenheit is " << f << "F";

     

      return 0;

}


This is the solution of this question




OUTPUT OF THIS QUESTION 

Input is highlighted with yellow color.


Explanation of this Solution

  1. Declare a float  variables for input.
  2. Declare another float variable for calculation.
  3. Take input from the user by using cin.
  4. Calculate the temperature by using formula.
  5.  In last, display output on the screen.
  6. Return 0 to the main function.

Also, I attach CPP file of this problem. You can download this file

Click Here to Download This File




Thanks! 


Post a Comment

0 Comments