Undeclared Identifier

Why am I getting this? Error C2065: 'height' : undeclared identifier

// Assignment 7.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
using namespace std;

int main() {

int height = 0;
int feet = 0;
int inches = 0;

cout << " Enter your height in inches :" << endl;
cin >> height;

feet = height / 12;
inches = height % 12;

cout << " You are " << feet << " feet and " << inches << "inches";

system("Pause");
return 0;
}
Last edited on
Error C2065: 'height' : undeclared identifier

That is not the complete error message. There is also line-number, where the error occurs. Some IDE's even highlight the part of code.


The code that you have posted does not have the error that you mention.
The error messages occur on lines 13, 15, and 16. I don't see the error either, but I'm afraid I'm doing something wrong because I'm new to this.

Is it possible that I shouldn't open it up in Win32?
Last edited on
Since the parameter 'height' is to be inputted from the keyboard and all the other parameters defend upon the value of 'height', you need not to declare the value of 'height' from the beginning (height=0). Instead just initialise thae variables as in;
Int height;
And since 'feet' is a fraction it should either be of type 'float' or 'double' i.e double feet;
double inches;
GOOD LUCK!
Topic archived. No new replies allowed.