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
- Declare a float variables for input.
- Declare another float variable for calculation.
- Take input from the user by using cin.
- Calculate the temperature by using formula.
- In last, display output on the screen.
- Return 0 to the main function.
Also, I attach CPP file of this problem. You can download this file
0 Comments