C++ Programming

C++ Programming

Freeform Project

The Freeform Project

In this project, you’ll learn to create a program that converts temperature from Fahrenheit to Celsius and vice versa. Generally, these project programs are going to be a bit extensive. These projects primarily involve a learning strategy that you must uphold. First, we grasp the program thoroughly and then we do it without having to look at it.

So without further due let’s get straight into it.

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float frh, cls, nfrh, ncls ;
cout<<"----------Temperature Conversion Menu----------";
cout<<"\n\n\nFahrenheit to Celsius\n\n";
cout<<"Input the temperature in Fahrenheit: ";
cin>>frh;
ncls=(frh-32.0)/1.8;
cout<<"Temperature in Celsius: "<<ncls;
cout<<"\n\n\nCelsius to Fahrenheit\n\n";
cout<<"Input the temperature in Celsius: ";
cin>>cls;
nfrh=(cls*1.8)+32.0;
cout<<"Temperature in Fahrenheit: "<<nfrh;
getch();
}

Formulas used in this program: Celsius= (Fahrenheit-32.0)/1.8

                                                         Fahrenheit= (Celsius*1.8)+32.0

This is what the variables symbolize:

frh- Fahrenheit
cls- Celsius
nfrh– New Fahrenheit(after conversion)
ncls- New Celsius(after conversion)

Execution of the Program

Now the program is quite self-explanatory. Now Compile the program. If the compiler shows errors then check my program and resolve it. Then Run the program. Here’s the output:

Now it’s time to do it yourself without having to look at the source code. Feel free to mess around with the program to understand in-depth what each statement does. Don’t forget to save your program.

That’s it for today, see you next week!!!