Beginner's Question Temp Conversion

Hello everyone,
I have a quiz in a few days, no classes in between now and the quiz and no friends in computer programming class. In order to do the quiz, I need to know how to do this exercise which I did not manage to complete in class.

"Write a function that will convert Fahrenheit to Celsius.
C = (5.0/9.0)(F-32.0).
Write a function prototype as well as a main that will print out the converted temperature (win 32 console application)".

I cannot figure out how to do this from my reading material or lecture notes. Can anyone tell me how or point me to an online document or tutorial on how to do this problem? Thanks.
this is too easy bro...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include <iostream>

float FtoC(float val)
{
	val-=32; val*=5; val/=9;
	return val;
}

float CtoF(float val)
{
	val*=9; val/=5; val+=32;
	return val;
}

void Func()
{

	float i;

	std::cout << "Enter fahrenheit value: ";
	std::cin >> i;
	std::cout << "The equivalent in Celsius is: ";
	std::cout << FtoC(i) << "\n";
//------------------------------------------------
	std::cout << "Enter Celsius value: ";
	std::cin >> i;
	std::cout << "The equivalent in fahrenheit is: ";
	std::cout << CtoF(i) << "\n";

}

int main()
{
	Func();
	int i; std::cin >> i;
	return 0;
}


took me like 3 minutes to type that up... it is basic math, how can you not figure it out from reading material? lol it is basic math, you do know the formula to convert right?

Celsius to Fahrenheit is : (°C × 9/5) + 32 = °F

Fahrenheit to Celsius is : (°F - 32) x 5/9 = °C
you do it the same exact way in computer programing :/
Last edited on
so did you get your homework? the least you could do is answer to see if you got it working or not...
Just a thing, don't use cin at the end... it requires you to enter a value.
I simply used it so the program doesn't exit, I think it should be obvious that it serves no real useful purpose here.
Topic archived. No new replies allowed.