nothingasis
In Runtime
- Messages
- 198
- Location
- CA
I have a formula that I'm trying to use to convert European gas consumption to U.S. gas consumption. When I punch it in the calculator I get the right answer but when i punch it into the computer it gives me a hex number. Is there a syntax error that I'm not catching or what do you guys think the problem is?
Btw:
12.41 liters / 100 km = 19 mi / g
#include <iostream>
using namespace std;
/*
Prototypes
*/
double convertToMPG(double);
/*
Main() Code
*/
int main()
{
cout << "Enter the number of liters per 100 km: ";
double liters;
cin >> liters;
convertToMPG(liters);
cout << liters << " liters/100km is " << convertToMPG << " mpg." << endl;
system ("pause");
return 0;
}
/*
function code
*/
double convertToMPG(double convertLiters)
{
double mpg;
mpg = .2641721;
mpg = mpg * convertLiters;
mpg = 62.14 / mpg;
return mpg;
}
Please and thank you!
Btw:
12.41 liters / 100 km = 19 mi / g
#include <iostream>
using namespace std;
/*
Prototypes
*/
double convertToMPG(double);
/*
Main() Code
*/
int main()
{
cout << "Enter the number of liters per 100 km: ";
double liters;
cin >> liters;
convertToMPG(liters);
cout << liters << " liters/100km is " << convertToMPG << " mpg." << endl;
system ("pause");
return 0;
}
/*
function code
*/
double convertToMPG(double convertLiters)
{
double mpg;
mpg = .2641721;
mpg = mpg * convertLiters;
mpg = 62.14 / mpg;
return mpg;
}
Please and thank you!