Question: In function ShowArea(), if areaPointer is null, print areaPointer is null.. Otherwise, print the value in the variable pointed to by areaPointer. End with a

In function ShowArea(), if areaPointer is null, print "areaPointer is null.". Otherwise, print the value in the variable pointed to by areaPointer. End with a newline. Ex: If the input is Y 3.0, then the output is: 3.0

code-------

#include #include using namespace std;

void ShowArea(double* areaPointer) {

/* Your code goes here */ if(areaPointer != nullptr) { cout << *areaPointer << endl; } else { (areaPointer == nullptr); cout << "areaPointer is null." << endl; } }

int main() { double area; double* areaPointer; char action; area = 0.0; cin >> action; cin >> area;

if (action == 'Y') { areaPointer = &area; } else { areaPointer = nullptr; } ShowArea(areaPointer);

return 0; }

-------

if input y 3.0 or anything .0, output drops the .0 Please help me figure out what I am missing.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!