Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ / This program demonstrates the use of pointer variables / / It finds the area of a rectangle given length and width / /
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
PLACE YOUR NAME HERE
#include
using namespace std;
int main
int length; holds length
int width; holds width
int area; holds area
int lengthPtr nullptr; int pointer which will be set to point to length
int widthPtr nullptr; int pointer which will be set to point to width
continues
LESSON SET Pointers
cout "Please input the length of the rectangle" endl;
cin length;
cout "Please input the width of the rectangle" endl;
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 "The area is area endl;
if Fill in the condition length width by using only the pointer variables
cout "The length is greater than the width" endl;
else if Fill in the condition of width length by using only the pointer
variables
cout "The width is greater than the length" endl;
else
cout "The width and length are the same" endl;
return ;
Exercise : Complete this program by filling in the code places in bold Note:
use only pointer variables when instructed to by the comments in bold.
This program is to test your knowledge of pointer variables and the & and
symbols.
Exercise : Run the program with the following data: Record the output
here
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