Basicly i have to make a program that calculates the distance between x

and y points in 2d space.

the code basicly goes like this

1. User says how many points they have (max of 10)

2. User enters points

3. Using sqrt( (x2-x1)^2 + (y2-y1)^2) ) It calculates the distance

between 2 points

4. It displays the length between the first and last point.

My problem is how do i accept the data. im not sure how to vary the

number of inputs or how to declare the variables. like say the user

wants 6 points how do i let the program know only to ask the user for 6

points. and then how do i do the same calculation for each of those

points.

i tried using a while loop and heres my code so far.

#include <iostream>;

#include <cmath.h>

using namespace std;

double length(double xa,double xb,double ya,double yb)

{

double length=0;

length=sqrt(((x b-xa)*(xb-xa))+((yb-ya)*(yb-ya)));

return (length);

}

int main()

int points=0;

int ans=0;

double length(double,d ouble,double,do uble)

double xa=0;

double xb=0;

double ya=0;

double yb=0;

cout <<"How many points would you like to input (Max 10)?\n\n";

cin >>points;

while (points 1)

{

cout <<"Please enter an x value\n";

cin >>xa;

cout <<"Please enter a y value\n";

cin >>ya;

cout <<"Please enter an x value\n";

cin >>xb;

cout <<"Please enter a y value\n";

cin >>yb;

ans=ans+length( xa,xb,ya,yb)

points=points-1;

}

return (0);

Im using VC++

i know the codes a little crappy but hey thats what help is for right

:)

Thanks in advance to any genius who can sort this mess out.