Ok, I have to write a function called distance that will calculate the distance between 2 points in an x-y coordinate system. Each point will be specified by 2 double values. Also, this function will not contain any input/output code (i.e. no printf or scanf function calls).
Write a complete program that will test your function.
How am I supposed to test my results, if I can't have no input/output code? Please help me.
This is my code, but I haven't finished it yet, because I don't know what to do after that. Please help.
Code:#include <stdio.h> #include <math.h> using namespace std; double distance(double xOne, double yOne, double xTwo, double yTwo) { double xS, yS, result; xS= xTwo - xOne; xS= xS*xS; // value of x squared under radical yS = yTwo - yOne; yS = yS*yS; //value of y squared under radical result = sqrt(xS + yS); return result; }



LinkBack URL
About LinkBacks


