I have a c++ assignment. Which is:
Write a C++ program to implement the following description:
- Define a global structure and name it GStruct with the following members: a. X as integer b. Y as integer.
- Define a local structure inside the main and name it LStruct with the following members: a. X as integer b. Y[3] as GStruct
- Inside the main declare two variables V1 and V2 of type LStruct.
- Give values to all of their members by using input statement (cin).
- If V1 equal V2 print "They are equal" else print "Not Equal".
I did everything that's asked from me and i got no errors. But it's not working like it's asked from me. Been working on this questions for more than 5 hours. It's driving me crazy. I went over it like 100 times and no use. Please help.... This is what i came up with and am sure it's all right but there is something missing but i don't know what it is.
#include <iostream>
using namespace std;
struct GStruct
{
int x;
int y;
};
int main()
{
struct LStruct
{
int x;
GStruct y[3];
};
LStruct V1;
LStruct V2;
cin>>V1.x;
cout<<V1.x<<endl;
for (int i=0; i<3;i++)
{
cin>>V1.y[i].x;
}
for (int i=0; i<3;i++)
{
cin>>V1.y[i].y;
}
cin>>V2.x;
cout<<V2.x<<endl;
for (int i=0; i<3;i++)
{
cin>>V2.y[i].x;
}
for (int i=0; i<3;i++)
{
cin>>V2.y[i].y;
}
for (int i=0; i<3; i++)
{
if (V1.y[i].x == V2.y[i].x && V1.y[i].y == V2.y[i].y && V1.x == V2.y)
continue;
else
cout<<"Not equal"<<endl;
}
return 0;
}