plz help me with this code

i have two functions here.i have declared two loops in function but i don't know how to print these loops value in another function.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void houseInfo::getdata()
{
	cout<<"enter the house entires"<<endl;
	
	for(int i=0;i<3; i++){
			cin>>avalible[i];
	}

	cout<<"enter the prices"<<endl;
	for(int j=0;j<3; j++)
	{
		cin>>prices[j];
	}}
void houseInfo::display()
{

	cout<<"The entries of house are"<<avalible[]<<endl;
	cout<<"the price of house is"<<price;
//i am confused here,i and j is giving error.becuse i and j are out of scope.what i should add instead of i and j here?

}
Last edited on
Well, I see that those are two separate functions, and they didn't take in anything. So I assumed avalible[] and prices[] are global variables.

I think the mistake is that you tried to cout arrays like this : cout << avalible[] , and cout << price .

You have to specify which position in the array to cout, like so: cout << avalible[1] . I can see that using a for-loop will work very well in this situation.

Also note that counting in C++ starts at 0. So an array of 3 numbers can be called with [0], [1], and [2].

Topic archived. No new replies allowed.