Below is a program I've written to convert a Fahrenheit value that the user inputs into the console window into the Celsius equivalent. Although the only answer I get is 0 and I don't know why.
#include <stdio.h>
#include <math.h>
int main()
{
int Celsius;
int Farenheit;
int Divide;
int Constant32;
Divide = 1.8;
Constant32 = 32;
printf("Enter a Farenheit value and hit return ");
scanf_s("%f" ,&Farenheit);
Celsius = (Farenheit-Constant32)/Divide;
printf ("%f" ,&Celsius);
Getchar();
I'm not sure if you are using C or C++.
Well with Dev-C++ I do this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
usingnamespace std;
int main();
{
float f;
float c;
cout<<"Enter a Fahrenheit value and hit return";
cin>>f;
cin.ignore();
c=(f-32)*5/9;
cout<<c;
cin.get();
}
I am still a beginner at C++ but that is what I would use.