Read the code below and answer the following questions: double y = 100; double *
ID: 3583351 • Letter: R
Question
Read the code below and answer the following questions: double y = 100; double *ptr = &y; int x = 7; Int *iptr = &x; Write a cout statement that uses the ptr variable to display the contents of the y variable What will be displayed if you send the expression *iptr to cout? What happens if you send the expression iptr to cout? Assuming that soap is an instance of the Inventory class, which of the following below is a valid call to the setOnHand member function. setOnHand (20); soap:: setOnHand (20); soap.setOnHand (20); Inventory.setOnHand(20); The following program contains errors. Find as many as possible. class circle: { private double centerX; double center; double radius; public SetCenter (double, double); setRadius (double); }Explanation / Answer
a)
cout<<*ptr;
The above statement uses the pointer variable ptr to print the value of y which is 100.
b)
cout<<*iptr will print you the value of x which is 7
c)
cout<<iptr will print you the address at which the variable x is stored. In my system "0xbffe509c" is printed.
d)you will use the instance to call the method from the class so correct answer is
C.soap.setOnHand(20);
e) ':' colons missing beside private and public
class should end with a semicolon ';' at the end
return types of SetCenter and setRadius is not declared
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.