Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ program Assume you want to model \"house\", which can have attributes, such

ID: 3761144 • Letter: C

Question

C++ program

Assume you want to model "house", which can have attributes, such as address, owner, lot_size, and year_built. Model your house struct with at least three (3) attributes. Then

-Define a function void initHouse (house &) that fills a house struct with some default values.
-Define a function bool compareHouse(house, house) that compares two houses and returns true if they are same, or false if they are different.

In you main function create two imaginary house variables and show the usage of these two functions in your code.

Explanation / Answer

#include <iostream>

#include<string>

using namespace std;

struct house

{

   string owner;

   int lot_size;

   int year_built;

};

void initHouse(house &node)

{

   node.lot_size = 10;

   node.year_built = 2010;

   node.owner = "John";

}

bool compare(house a,house b)

{

  

   if(a.lot_size==b.lot_size && a.year_built==b.year_built && a.owner==b.owner)

       return true;

   else

       return false;

}

int main()

{

   house a,b;

   initHouse(a);

   initHouse(b);

   cout << "Houses are similar : " << compare(a,b);

    return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote