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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started