Question
I need to complete this C++ program. The instructions are in the green commentaries. // This program demonstrates the use of pointer variables // It
I need to complete this C++ program. The instructions are in the green commentaries. // This program demonstrates the use of pointer variables
// It finds the area of a rectangle given length and width
// It prints the length and width in ascending order
#include
using namespace std;
int main()
{
int length; // holds length
int width; // holds width
int area; // holds area
int *lengthPtr; // int pointer which will be set to point to length
int *widthPtr; // int pointer which will be set to point to width
cout
cin >> length;
cout
cin >> width;
// Fill in code to make lengthPtr point to length (hold its address)
// Fill in code to make widthPtr point to width (hold its address)
area = // Fill in code to find the area by using only the pointer variables
cout
if (// Fill in the condition of length > width by using only the pointer variables)
cout
else if (// Fill in the condition of width > length by using only the pointer
// variables)
cout
else
cout
return 0;
}
// This program demonstrates the use of pointer variables // It finds the area of a rectangle given length and widtlh // It prints the length and width in ascending order #include iostream using namespace std; in main() int, length; in width; // holds length // holds width // holds area area; *lengthEtc; //pointer which will be set to point to length int * // jnt.pointer which will be set to point to width Sout > width; // Fill in code to make lengthpoint to length (hold its address) // Fill in code to makeidtbRtr point to width (hold its address) areaL/ Fill in code to find the area by using only the pointer variables sautStep 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