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

Declare a structure Phone that has three int fields called country, area and num

ID: 3618546 • Letter: D

Question

Declare a structure Phone that has three int fields called country, area and number. In main,declare a pointer variable to a Phone structure named new Phone. Then write assignment statements to indirectly (using the pointer) store the values 1, 888 and 5551122 into these fields. Write a Boolean value returning function called Shallow Compare that takes two variables of type pointer to phone structure (declared | in part a), and returns true if they point to the same structure, and false otherwise. For (a) Output should be like this : Country code :1 Area code :888 Number :5551122 For (b) Output should be like this : Two structure variables are pointing to same structure . //if returns true; Two structure variables are not pointing to same structure . //if returns false;

Explanation / Answer

#include struct Phone {    int CountryCode;    int Area;    long PhoneNumber; }; bool ShallowCompare(struct Phone* objPhone1,struct Phone*objPhone2) {        if(objPhone1 == objPhone2)        return true;       return false; } int main() {    struct Phone* objPhone;     objPhone->CountryCode = 1;    objPhone->Area = 888;     objPhone->PhoneNumber= 5551122;    struct Phone* objCopyPhone;     objCopyPhone = objPhone;    struct Phone* objSecPhone;     objSecPhone->CountryCode = 2;    objSecPhone->Area = 999;     objSecPhone->PhoneNumber= 6661122;    cout
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