Chapter 3 – #12: 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>
#include <iomanip>
using namespace std;

int main()
{
    // Variables
    float F,
          C;

    // Ask user Celsius Temp
    cout << "\nEnter the Celsius Temp: ";
    cin >> C;

    // Calculate Fahrenheit
    F = ((9.0 / 5.0) * C) + 32;

    // Display Fahrenheit
    cout << setprecision(1) << fixed << right << endl;
    cout << "Celsius    Temp = " << setw(6) << C << endl;
    cout << "Fahrenheit Temp = " << setw(6) << F << endl;
    cout << endl;

    return 0;
}

>_Get The Book!

>_ Video Walk Through

This video includes a step by step process of how I solve programming challenge #12.

>_ Chapter 3 Programming Playlist

>_That’s it!

Thank you for taking interest in what I do! I hope it was helpful for you as much as it helped me along my journey in learning to code!

>_All Chapter 3 Posts:

Category: Starting Out With C++ | Chapter 3 | Programming Challenge Solutions

Leave a Reply