arith-example2 - Prompt for and cout<<"x" read...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// Programmer: Hogan // Section: 0 // Program: Demo program: Midpoint // Date: September 24, 2005 // Description: This program takes in two ordered pairs and finds their // midpoint. #include <iostream.h> // for cin, cout, endl int main () { double x1; // x-coordinate of first point double y1; // y-coordinate of first point double x2; // x-coordinate of second point double y2; // y-coordinate of second point cout << "This program finds the midpoint of any two points." << endl; cout << "Enter point 1 coordinates: " << endl;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // Prompt for and cout << "x? "; // read in 1st point cin >> x1; cout << "y? "; cin >> y1; cout << "Enter point 2 coordinates: " << endl; // Prompt for and cout << "x? "; // read in 2nd point cin >> x2; cout << "y? "; cin >> y2; cout << "Coordinates of the midpoint: " << endl; // Calculate and print cout << "x: " << (x1 + x2) / 2.0 << endl; // the midpoint by cout << "y: " << (y1 + y2) / 2.0 << endl; // averaging coordinates // one at a time return 0; }...
View Full Document

This document was uploaded on 02/10/2011.

Ask a homework question - tutors are online