Site hosted by Angelfire.com: Build your free website today!

This program is pretty niffty, it will find the slope equation of a line when you enter 4 points, like (x,y) (x1,y1) and the slope equation is then displayed for you.



Want to Download the Program?


This is the Code for The Program.


#include <stdio.h> #include "iostream.h" void getapoint(double & x,double & y); double getslope(double x, double y, double x1, double y1); double getb(double x, double y, double m); int main(void) { double m,b,x=0,y=0,x1=0,y1=0; while(100){ getapoint(x,y); getapoint(x1,y1); m=getslope(x,y,x1,y1); b=getb(x1,y1,m); if ((x1-x)==0) cout<<"X="<<x; else cout<<"The line that passes through "<<"("<<x<<","<<y<<")"<< " and "<<"("<<x1<<","<<y1<<")\nhas a slope equation of ("<<"Y=" <<m<<"X"<<"+"<<b<<")\n\n"; } } void getapoint(double & x,double & y) { cout<<"Give me 2 cordinate points "; cin>>x>>y; } double getslope(double x, double y, double x1, double y1) { return ((y1-y)/(x1-x)); } double getb(double x1, double y1, double m) { return (y1-(m*x1)); }