for(int i=0;i<3; i++){
cout<<"enter the entries"<<endl;//help me in this portion,first loop for house entries
cin>>avalible[i];
}
{
for(int j=0;j<3;j++)//this loop is for price.
cin>>avalible[j];
}
}
cout<<"the house entries and price is"<<avalible[i][j];//i am confused here,i and j is giving error.what i should add instead of i and j here?
Your last line is outside of the {}-braces of your for-loop. Hence, i and j do not exist anymore at that point.
Also, you will probably need two separate arrays (or create a struct for a house), one for prices and one for houses:
i wirote a program in which i declare a class called house info,i am having trouble of displaying no of house entries and things.i have declard an array name avalible[3],it gets input in function getdat() but not giving any output.
class houseInfo
{
string ownersName;
string adress;
int bedrooms;
longint price;
string avalible[3];
public:
void getdata();
void display();
};
void houseInfo::getdata()
{
int value;
cout<<"Enter The Owner's Name"<<endl;
cin>>ownersName;
cout<<"Enter The Adress"<<endl;
cin>>adress;
cout<<"Enter The Bedrooms"<<endl;
cin>>bedrooms;
cout<<"Enter The Price"<<endl;
cin>>price;
cout<<"enter the house entires and price"<<endl;
for(int i=0;i<3; i++){
cin>>avalible[i];
}
{
for(int j=0;j<3;j++)
cin>>avalible[j];
}
}
void houseInfo::display()
{
cout<<"The Name Of The Owner Is"<<' '<<ownersName<<endl;
cout<<"The Adress Of The Employer Is"<<' '<<adress<<endl;
cout<<"The Number Of Bedrooms Are"<<' '<<bedrooms<<endl;
cout<<"The Price Of The House Is"<<' '<<price<<endl;
cout<<"the house entries and price is"<<avalible;//i am confused here,i and j is giving error.what i should add instead of i and j here?
}
int main(){
houseInfo house;
cout<<"\t \t \t Wellcome To Information System"<<endl;
cout<<"\t \t \t -----------------------------"<<endl<<endl;
house.getdata();
house.display();
getch();
return 0;
}
@Mehdinaqvi what is the exact error code you get ?
------------------------------------------------
Your other errors:
1 2 3 4 5 6 7 8
for(int i=0;i<3; i++){
cin>>avalible[i];
}
{ // you have an extra brace here i think you want to put this beside the for loop below
for(int j=0;j<3;j++) // I think you want a curly brace here '{'
cin>>avalible[j];
}
} // you also have an extra brace here
you overwrite the data you have just stored in available, i think you want a separate array for the price of the houses
cout<<"the house entries and price is"<<avalible;
I think you want to print the contents of the array available which should be accessed by available[0] ...and so on
In that case, you want to put it inside a for loop