[Help] Celsius To Fahrenheit

Posts 1–3 of 3 · Page 1 of 1
[Help] Celsius To Fahrenheit
Hello everyone,

I just started learning C++ and I was trying to make a Celsius To Fahrenheit converter, but I got an error.

Here's the code:

Code:
#include <iostream>

using namespace std;

int main()
{
	double C;
	cout << "Enter your degrees in celsius: ";
	cin >> C;
	temp(C);
	cout << "Done!";
	cin.get();
	cin.get();
	return 0;
}

void temp(double ctemp)
{
	double F = ctemp * 1.8 + 32; 
	cout << ctemp << " Celsius = " << F << "Fahrenheit.";
}
So what's wrong with this?

The error said: error C3861: 'temp': identifier not found

Thanks..
Change your code to this:

Code:
#include <iostream>

using namespace std;

void temp(double ctemp);

int main()
{
	double C;
	cout << "Enter your degrees in celsius: ";
	cin >> C;
	temp(C);
	cout << "Done!";
	cin.get();
	cin.get();
	return 0;
}

void temp(double ctemp)
{
	double F = ctemp * 1.8 + 32; 
	cout << ctemp << " Celsius = " << F << "Fahrenheit.";
}
You didnt declare this in the beginning of the program
Quote Originally Posted by aanthonyz View Post
Change your code to this:

Code:
#include <iostream>

using namespace std;

void temp(double ctemp);

int main()
{
	double C;
	cout << "Enter your degrees in celsius: ";
	cin >> C;
	temp(C);
	cout << "Done!";
	cin.get();
	cin.get();
	return 0;
}

void temp(double ctemp)
{
	double F = ctemp * 1.8 + 32; 
	cout << ctemp << " Celsius = " << F << "Fahrenheit.";
}
You didnt declare this in the beginning of the program
Ow yeah thanks.. I forgot that
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Need help?