// this program converts gallons to liters using function calls
#include <iostream>
using namespace std;
double mpg(double liters, double gallons);
int main ()
{
int liters, gallons;
double miles;
cout << "How many liters did your car consume?\n";
cin >> liters;
miles = mpg(liters, gallons);
cout << miles << endl;
return 0;
}
double mpg(double liters, double gallons)
{
const double GALLONS = .264179; // Liter in one gallon
double mpg;
mpg = liters * gallons;
return (mpg);
}
getting an error once i compile using Microsoft Visual saying the variable gallons is being sued without being defined, its my first time using a function call and i have no idea how to fix this, the program runs but once i enter the number of liters that error just pops up
Tags: