Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please use C + + , 3 Struct Data Types Use program Distance for Exercise 3 . / / Program Distance gets user inputs for
Please use C
Struct Data Types
Use program Distance for Exercise
Program Distance gets user inputs for the x y coordinates
of two points, then calculates the distance between the two
points and prints the result.
#include
#include
using namespace std;
struct Point
double x;
double y;
;
void printPoint Point p
cout.precision;
cout fixed showpoint;
cout px py ;
return;
Point readPoint
Point p;
cout "Enter point x y: ;
cin px py;
return p;
int main
Point p p;
p readPoint;
p readPoint;
cout "The distance between ;
printPointp;
cout and ;
printPointp;
cout is PointDistancepp endl;
return ;
Exercise :
Create a function called PointDistance that calculates distance between the two points. It should be a
double valuereturning function that accepts two parameters both of type Point. Dont forget to use the
sqrt function.
Run the program and enter the results for the following data. In your lab report, also include the
modified cpp file.
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