#include <iostream>	
using namespace std;


int CelsiustoFahrenheit()
{
   
	
float celsius;
    cin >> celsius;
    
float fahrenheittemp;
    fahrenheittemp =  celsius * 1.8 +32;
    
   
   
};




int FahrenheittoCelsius()
{
   
float celsiustemp;	
float fahrenheittemp;
 cin >> fahrenheittemp;
celsiustemp =  (fahrenheittemp-32)/1.8 ;
 
};


int main()
{
	int choice;
	float celsiustemp,fahrenheittemp; 
	cout << "1.Celsius to Fahrenheit" << endl;
	cout << "2.Fahrenheit to Celsius" << endl;
	cout << "Choose between 1 & 2 : " << endl;
	cin>>choice;
	if (choice==1)
		{
			cout << "Enter the temperature in Celsius : " << endl;
			cin>>celsiustemp;
			fahrenheittemp=(1.8*celsiustemp)+32;
			cout << "Temperature in Fahrenheit = " << FahrenheittoCelsius()<< endl;

			return 0;
		}
		
		else
				
		{
			cout << "Enter the temperature in Fahrenheit : " << endl;
			cin>>fahrenheittemp;
			celsiustemp=(fahrenheittemp-32)/1.8;
			cout << "Temperature in Celsius = " << CelsiustoFahrenheit() << endl;

			return 0;
		}


	
}

Recommended Answers

All 4 Replies

When posting code always use code-tags!

You have two functions that should return a value, but don't: int CelsiustoFahrenheit() and int FahrenheittoCelsius() After calculating the values you'll have to return them from the function, because it makes no sense in calculating them if you're not going to use them right?
So in the first function add return fahrenheittemp; and in the second return celsiustemp; Why are you using an int anyway? Temperatures aren't always integer values you know.

// example
int func(void)
{
   int i=0;
   return i; // return value
}

You didn't want to try out the Kelvin one I posted, too?

Your functions should except parameters too:

double cubeit(double value)
{
  return(value * value * value);
}

use it like:

double x;
cin >> x;
x = cubeit(x);
cout << x << endl;

Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.