Site icon T4Tutorials.com

Program to convert temperature in Celsius to Fahrenheit in c++ and C with flowchart

Program to convert a temperature in Celsius to Fahrenheit in c++ and C with the flowchart.

Given F = 9 5 C + 32, the conversion formula for Fahrenheit to Celsius, solve for C.

2.

Celsius to Fahrenheit progam C++ Diagram

Flowchart of a program to convert a temperature in Celsius to Fahrenheit 

Program to convert temperature in Celsius to Fahrenheit in c++ and C
Figure: Flowchart of a program to convert a temperature in Celsius to Fahrenheit

Program to convert a temperature in Celsius to Fahrenheit in c++

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
 float C; 
 float F;
  cout<<"input temperature in Celsius is= ";
  cin>>C;
   F= C * 9/5 + 32;
  cout<<"Temperature in Fahrenheit is= "<<F;
 getch();
}

Output

program in c++ to convert the temperature in celsius to fahrenheit
Figure: program in c++ to convert the temperature in Celsius to Fahrenheit.
c++ temperature conversion
c++ temperature conversion

 

 

 

 

 

dry run of C++ Program to convert a temperature in Celsius to Fahrenheit
dry run of C++ Program to convert a temperature in Celsius to Fahrenheit

 

Program to convert a temperature in Celsius to Fahrenheit in C

#include <stdio.h>
int main()
{
    float C;
    float F;
    
    printf("input temperature in Celsius: ");
    scanf("%f", &C);

   F = (C * 9 / 5) + 32;

    printf("%.2f Celsius = %.2f Fahrenheit=", C, F);

    return 0;
}

Output

program in c++ to convert the temperature in celsius to fahrenheit
Figure: program in c++ to convert the temperature in Celsius to Fahrenheit

Celsius to Fahrenheit C++ while loop

#include <iostream>
using namespace std;
int main() {
    float T4Tutorials_Celsius;
    float T4Tutorials_fahrenheit;
  cout << " Celsius to fahrenheit conversion." << endl; 
    while (cin >> T4Tutorials_Celsius) {                // (1)
        T4Tutorials_fahrenheit = 1.8 * T4Tutorials_Celsius + 32;
        cout << " fahrenheit = " << T4Tutorials_fahrenheit << endl;
    } 
    return 0;
}

Celsius to Fahrenheit C++ for loop

Writ a celsius  C++ program to show the Fahrenheit table.

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    float T4Tutorials_fahrenheit = 0;

    cout << endl;
    cout << "*****************\n";
    cout << "Celsius\t\tFahrenheit" << endl;
    cout << "*****************\n";
    cout << setprecision(1) << fixed << right;
    cout.fill('0');
    for (int T4Tutorials_Celsius = 0; T4Tutorials_Celsius <= 20; T4Tutorials_Celsius++)
    {
        // Calculate Fahrenheit
        T4Tutorials_fahrenheit = ((9.0 / 5) * T4Tutorials_Celsius) + 32;
        cout << setw(2) << T4Tutorials_Celsius << "\t\t" << T4Tutorials_fahrenheit << endl;
    }
    cout << "*****************\n";
    return 0;
}

c++ celsius to fahrenheit table loop

shamil memory table

Exit mobile version