Variable not declared in this scope

Was trying out the example in my textbook but keep hitting this error 'sizeofYardInSqFeet' was not declared in this scope" when I try to compile it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
using namespace std;

int main()

{
	int hoursGone;
	const int MANY_HOURS = 6;
	char haveYard;
	int sizeOfYardInSqFeet;
	const int SMALL_YARD = 400;
	const int LARGE_YARD = 2500;
	cout << "On average, how many hours are you gone from home each day? ";
	cin >> hoursGone;
	if (hoursGone > MANY_HOURS)
	cout << "You should consider a cat" << endl;
	else
	{
		
                cout <<"Do you have a fenced yard? Y or N";
		cin >> haveYard;
		cout << "You can consider a dog, ";
		if (haveYard == 'N' || haveYard == 'n')
		cout << "but a small breead such as a Chihuahua" << endl;

		else
	{

		cout << "but you can consider a larger breed" << endl;
		cout << "What is the size of your yard in square feet? ";
		cin >> sizeOfYardInSqFeet;
		if (sizeofYardInSqFeet <= SMALL_YARD)
		cout << "Consider a Schnauzer" << endl;

		else 
                if (sizeofYardInSqFeet <= LARGE_YARD)
		cout << "Consider a Golden or Labrador Retriever" << endl;

		else
		cout <<"You can consider a Great Dane" << endl;
	}

	}

	return 0;

}

Last edited on
Variables are case-sensitive. The of needs to be capitalized as you did in the declaration of the variable.
Thanks. I need to make lesser of such mistake >.<
Topic archived. No new replies allowed.