66 840
Assignments Done
99,1%
Successfully Done
In October 2018

Answer to Question #16435 in C++ for arif hussain

Question #16435
Q#3 Write a program that uses a structure called point to model a point. Define three points, and have the user input values to two of them. Then set the third point equal to the sum of the other two, and display the value of the new point
Expert's answer
C++
Write a program that uses a structure called point to model a point. Define three points, and have the user input values to two of them. Then set the third point equal to the sum of the other two, and display the value of the new point

#include<iostream>
using namespace std;

struct p{
float x, y, z;
} p1, p2, p3;

void main(){
cout<<"enter x, y, z coords for the 1st point: ";
cin>>p1.x>>p1.y>>p1.z;
cout<<"enter x, y, z coords for the 2nd point: ";
cin>>p2.x>>p2.y>>p2.z;
p3.x = p1.x + p2.x;
p3.y = p1.y + p2.y;
p3.z = p1.z + p2.z;
cout<<"sum of the given points is: p3("<<p3.x<<", "<<p3.y<<", "<<p3.z<<").\n";
system("pause");
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions