//lab 8a1
#include <iostream>
using namespace std;
void get2Points(float& x1, float& y1, float& x2, float& y2);
int main()
{
float x1,x2,y1,y2;
get2Points(x1,y1,x2,y2);
cout << "Coordinate 1 : " << x1 << "," << y1 << endl;
cout << "Coordinate 2 : " << x2 << "," << y2 << endl;
return 0;
}
void get2Points(float& x1, float& y1, float& x2, float& y2)
{
cout << "Enter x1 : ";
cin >> x1;
cout << "Enter y1 : ";
cin >> y1;
cout << "Emter x2 : ";
cin >> x2;
cout << "Enter y2 : ";
cin >> y2;
}
using namespace std;
void get2Points(float& x1, float& y1, float& x2, float& y2);
int main()
{
float x1,x2,y1,y2;
get2Points(x1,y1,x2,y2);
cout << "Coordinate 1 : " << x1 << "," << y1 << endl;
cout << "Coordinate 2 : " << x2 << "," << y2 << endl;
return 0;
}
void get2Points(float& x1, float& y1, float& x2, float& y2)
{
cout << "Enter x1 : ";
cin >> x1;
cout << "Enter y1 : ";
cin >> y1;
cout << "Emter x2 : ";
cin >> x2;
cout << "Enter y2 : ";
cin >> y2;
}
#include <iostream>
using namespace std;
void get2Points(float& x1, float& y1, float& x2, float& y2);
void slopeInterceptFrom2points(float x1, float y1, float x2, float y2, float& m, float& c);
int main()
{
float x1,x2,y1,y2,m,c;
get2Points(x1,y1,x2,y2);
slopeInterceptFrom2points(x1,y1,x2,y2,m,c);
cout << "Coordinate 1 : " << x1 << "," << y1 << endl;
cout << "Coordinate 2 : " << x2 << "," << y2 << endl;
cout << "Slope is : " << m << endl;
cout << "Intercept is : " << c << endl;
return 0;
}
void get2Points(float& x1, float& y1, float& x2, float& y2)
{
cout << "Enter x1 : ";
cin >> x1;
cout << "Enter y1 : ";
cin >> y1;
cout << "Emter x2 : ";
cin >> x2;
cout << "Enter y2 : ";
cin >> y2;
}
void slopeInterceptFrom2points(float x1, float y1, float x2, float y2, float& m, float& c)
{
m = (y2-y1)/(x2-x1);
c = y1 - m*x1;
}
using namespace std;
void get2Points(float& x1, float& y1, float& x2, float& y2);
void slopeInterceptFrom2points(float x1, float y1, float x2, float y2, float& m, float& c);
int main()
{
float x1,x2,y1,y2,m,c;
get2Points(x1,y1,x2,y2);
slopeInterceptFrom2points(x1,y1,x2,y2,m,c);
cout << "Coordinate 1 : " << x1 << "," << y1 << endl;
cout << "Coordinate 2 : " << x2 << "," << y2 << endl;
cout << "Slope is : " << m << endl;
cout << "Intercept is : " << c << endl;
return 0;
}
void get2Points(float& x1, float& y1, float& x2, float& y2)
{
cout << "Enter x1 : ";
cin >> x1;
cout << "Enter y1 : ";
cin >> y1;
cout << "Emter x2 : ";
cin >> x2;
cout << "Enter y2 : ";
cin >> y2;
}
void slopeInterceptFrom2points(float x1, float y1, float x2, float y2, float& m, float& c)
{
m = (y2-y1)/(x2-x1);
c = y1 - m*x1;
}
#include <iostream>
using namespace std;
void get2Points(float& x1, float& y1, float& x2, float& y2);
void slopeInterceptFrom2points(float x1, float y1, float x2, float y2, float& m, float& c);
void getPtSlope(float& x, float& y, float& m);
int main()
{
float x1,x2,y1,y2,m1,c1;
float x, y, m;
int sel;
cout << "Type selection : ";
cin >> sel;
if (sel==3)
{
getPtSlope(x,y,m);
cout << "Coordinate 1 : " << "(" << x << "," << y << ")" << endl;
cout << "Slope " << m << endl;
}
else
{
get2Points(x1,y1,x2,y2);
slopeInterceptFrom2points(x1,y1,x2,y2,m1,c1);
cout << "Coordinate 1 : " << x1 << "," << y1 << endl;
cout << "Coordinate 2 : " << x2 << "," << y2 << endl;
cout << "Slope is : " << m1 << endl;
cout << "Intercept is : " << c1 << endl;
}
return 0;
}
void get2Points(float& x1, float& y1, float& x2, float& y2)
{
cout << "Enter x1 : ";
cin >> x1;
cout << "Enter y1 : ";
cin >> y1;
cout << "Emter x2 : ";
cin >> x2;
cout << "Enter y2 : ";
cin >> y2;
}
//lab 8a4
using namespace std;
void get2Points(float& x1, float& y1, float& x2, float& y2);
void slopeInterceptFrom2points(float x1, float y1, float x2, float y2, float& m, float& c);
void getPtSlope(float& x, float& y, float& m);
int main()
{
float x1,x2,y1,y2,m1,c1;
float x, y, m;
int sel;
cout << "Type selection : ";
cin >> sel;
if (sel==3)
{
getPtSlope(x,y,m);
cout << "Coordinate 1 : " << "(" << x << "," << y << ")" << endl;
cout << "Slope " << m << endl;
}
else
{
get2Points(x1,y1,x2,y2);
slopeInterceptFrom2points(x1,y1,x2,y2,m1,c1);
cout << "Coordinate 1 : " << x1 << "," << y1 << endl;
cout << "Coordinate 2 : " << x2 << "," << y2 << endl;
cout << "Slope is : " << m1 << endl;
cout << "Intercept is : " << c1 << endl;
}
return 0;
}
void get2Points(float& x1, float& y1, float& x2, float& y2)
{
cout << "Enter x1 : ";
cin >> x1;
cout << "Enter y1 : ";
cin >> y1;
cout << "Emter x2 : ";
cin >> x2;
cout << "Enter y2 : ";
cin >> y2;
}
//lab 8a4
#include <iostream>
using namespace std;
void get2Points(float& x1, float& y1, float& x2, float& y2);
void slopeInterceptFrom2points(float x1, float y1, float x2, float y2, float& m, float& c);
void getPtSlope(float& x, float& y, float& m);
float interceptFromPtSlope(float x,float y,float m);
int main()
{
float x1,x2,y1,y2,m1,c1;
float x, y, m, c;
int sel;
cout << "\n ...Welcome...\n";
cout << endl <<"To get just intercept , type 1.\n" << "To get slope & intercept , type any other value.\n";
cout << "Type selection : ";
cin >> sel;
if (sel==1)
{
getPtSlope(x,y,m);
cout << "\nCoordinate 1 : " << "(" << x << "," << y << ")" << endl;
cout << "Slope " << m << endl;
c = interceptFromPtSlope(x,y,m);
cout << "Y intercept is : " << c << endl;
cout << "\nEquation is : " << "y = " << m << "x + " << c << endl;
}
else
{
get2Points(x1,y1,x2,y2);
slopeInterceptFrom2points(x1,y1,x2,y2,m1,c1);
cout << "\nCoordinate 1 : " << x1 << "," << y1 << endl;
cout << "Coordinate 2 : " << x2 << "," << y2 << endl;
cout << "Slope is : " << m1 << endl;
cout << "Intercept is : " << c1 << endl;
cout << "\nEquation is : " << "y = " << m << "x + " << c << endl;
}
cout << "\n ...Have a nice day...\n\n";
return 0;
using namespace std;
void get2Points(float& x1, float& y1, float& x2, float& y2);
void slopeInterceptFrom2points(float x1, float y1, float x2, float y2, float& m, float& c);
void getPtSlope(float& x, float& y, float& m);
float interceptFromPtSlope(float x,float y,float m);
int main()
{
float x1,x2,y1,y2,m1,c1;
float x, y, m, c;
int sel;
cout << "\n ...Welcome...\n";
cout << endl <<"To get just intercept , type 1.\n" << "To get slope & intercept , type any other value.\n";
cout << "Type selection : ";
cin >> sel;
if (sel==1)
{
getPtSlope(x,y,m);
cout << "\nCoordinate 1 : " << "(" << x << "," << y << ")" << endl;
cout << "Slope " << m << endl;
c = interceptFromPtSlope(x,y,m);
cout << "Y intercept is : " << c << endl;
cout << "\nEquation is : " << "y = " << m << "x + " << c << endl;
}
else
{
get2Points(x1,y1,x2,y2);
slopeInterceptFrom2points(x1,y1,x2,y2,m1,c1);
cout << "\nCoordinate 1 : " << x1 << "," << y1 << endl;
cout << "Coordinate 2 : " << x2 << "," << y2 << endl;
cout << "Slope is : " << m1 << endl;
cout << "Intercept is : " << c1 << endl;
cout << "\nEquation is : " << "y = " << m << "x + " << c << endl;
}
cout << "\n ...Have a nice day...\n\n";
return 0;
0 comments:
Post a Comment