Having trouble. I keep getting error C2065

I'm doing a program for class, trying to make a conversion for feet, inches, miles, and yards to meters, but I keep getting the error C2065 message. This is the program as I've made it so far:


#include <iostream>
using namespace std;

int main ()
{
const int FEET_PER_MILE = 5280;
const int YARDS_PER_MILE = 1760;
const int FEET_PER_YARD = 3;
const int INCHES_PER_YARD = 36;
const int INCHES_PER_FOOT = 12;
const float METERS_PER_INCH = 0.0254;

cout << "Enter the yards:";
cin >> yards;
meters = yards*INCHES_PER_YARD*METERS_PER_INCH;

cout << "Enter the feet:";
cin >> feet;
meters = feet*INCHES_PER_FOOT*METERS_PER_INCH;

cout << "Enter the miles:";
cin >> miles;
meters = miles*YARDS_PER_MILE*INCHES_PER_YARD*METERS_PER_INCH;

cout << "Enter the inches:";
cin >> inches;
meters = inches *METERS_PER_INCH;

system("pause");
return(0);
}

The error happens in the second and third lines of each conversion, saying that, for example:
ConversionTable2.cpp(14) : error C2065 : 'yards' : undeclared identifier
ConversionTable2.cpp(15) : error C2065 : 'meters' : undeclared identifier
ConversionTable2.cpp(15) : error C2065 : 'yards' : undeclared identifier

I need some help. Can anyone tell me what I'm doing wrong?
undeclared identifier

You didn't declare anything at all but the constants.
So what do I need to do to get it to work right? My textbooks haven't been any help at all...
closed account (zb0S216C)
Give the specified variables a type identifier such as int, char, float...
See here: http://www.cplusplus.com/doc/tutorial/variables/
Thank you. You helped a lot!
Topic archived. No new replies allowed.