Does any one can help about this c++ program:
A program in which you define two separate arrays of type Property
data structure (in lecture II) and uses pointers to compare, find and
print out those elemnts of arrays which are equal in both arrays; values for
house, car and boat are the same.*/
#include <iostream>
using namespace std;
struct Property{
char house[10];
unsigned short car;
unsigned short boat;
};
int main() {
int i;
Property Friends[] = { {"Yes", 0, 2}, {"No",1, 0}, {"No", 0, 0} };
Property Friend[] = { {"Yes", 0, 2}, {"No",1, 0}, {"No", 0, 0} };
Property *p,*p1;
p=Friends;
p1=Friend;
while(*p==*p1)
{
if(*p == *p1)
{
(p)++;
(p1)++;
}
else
{
for(i=0; i<3; i++)
{
cout<<"\nFriends "<<(i+1)<<" owns a house? "<<p[i].house;
cout<<"\tFriends "<<(i+1)<<" owns "<<p[i].car<<"car(s).";
cout<<"\tFriends "<<(i+1)<<" owns "<<p1[i].boat<<"boat(s).";
(p)++;
(p1)++;
}
- #include <iostream>
- using namespace std;
- struct Property{
- char house[10];
- unsigned short car;
- unsigned short boat;
- };
- int main() {
-
- int i;
- Property Friends[] = { {"Yes", 0, 2}, {"No",1, 0}, {"No", 0, 0} };
- Property Friend[] = { {"Yes", 0, 2}, {"No",1, 0}, {"No", 0, 0} };
- Property *p,*p1;
- p=Friends;
- p1=Friend;
- while(*p==*p1)
-
- {
- if(*p == *p1)
- {
- (p)++;
- (p1)++;
- }
-
- else
- {
-
- for(i=0; i<3; i++)
- {
- cout<<"\nFriends "<<(i+1)<<" owns a house? "<<p[i].house;
- cout<<"\tFriends "<<(i+1)<<" owns "<<p[i].car<<"car(s).";
- cout<<"\tFriends "<<(i+1)<<" owns "<<p1[i].boat<<"boat(s).";
- (p)++;
- (p1)++;
- }