Checked It Please if anY error Please correct...

Pages: 1234
@cire how can u have a negative change if t starts at 4 and ends at -12 that is a 16 change and ya I forgot the absolute but 4--12,=16 problem I didn't think was -4-12 =-16 and not 16 but abs should.solve that and you can still use doubles 4.2--10.56= 14.76 change you just have to be careful with the == 0 if itts a double
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <conio.h>
using namespace std;
// main part of the program
main() 
{
      int slope;
      int X1;
      int Y1;
      int X2;
      int Y2;
      int dy;
      int dx;
      cout<<"Enter the X-coordinate of the starting point";
      cin>>X1;
      cout<<"Enter the Y-coordinate of the starting point";
      cin>>Y1;
      cout<<"Enter the X-coordinate of the ending point";
      cin>>X2;
      cout<<"Enter the Y-coordinate of the ending point";
      cin>>Y2;
      //Formula Section
      dy = Y2 - Y1;
      dx = X2 - X1;
      slope = dy/dx; 
if (slope == 1)
      cout<<"Line will make the 45 degree angle with the horizon"<<endl;
else if ( resultSlope < 1 )
      cout<<"Line will travel more along X-Axis and Less along Y-Axis"<<endl;
else if ( resultSlope > 1 )
      cout<<"Line will travel more along Y-Axis and Less along X-Axis"<<endl;
if (dx == 0)
      cout<<" Line is parallel to Y-Axis";
if (dy == 0)
      cout<<" Line is parallel to X-Axis";
      cout<<"Press any Key to continue...." ;
      getch();
}




This program is not complaing Error ... Also check Formulas..
Probably because u have result slope and not dx < dy just fix line 28 30 and u don't need the divide if one is bigger than other it moves more along that axis oh and don't forget the abs of dxand du u can either use the math header abs() or if (dx < 1) dx *= -1 and same for dy
Last edited on
@giblit iostream: No such file or directory.
Error is in #include <iostream>
Try a c++ compiler
@ne555 I am using C++ compiler
You have a major flaw in your design then if you're getting that error
the major flaw is ? if u can mention the flaw. Please @giblit
Then how are you getting that error ? Which ide are you using and maybe post full code
I don't know how i have the errors :(
> I am using C++ compiler
¿which one? It may be previous to 1998 if it doesn't have `iostream'

Try gcc 4.8
Last edited on
Which ide? And you have the #include <iosream> at the top out of your function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include<conio.h>
using namespace std;
main() // main part of the program
{
      int slope;
      int X1;
      int Y1;
      int X2;
      int Y2;
      int dy;
      int dx;

      cout<<"Enter the X-coordinate of the starting point";
      cin>>X1;
      cout<<"Enter the Y-coordinate of the starting point";
      cin>>Y1;
      cout<<"Enter the X-coordinate of the ending point";
      cin>>X2;
      cout<<"Enter the Y-coordinate of the ending point";
      cin>>Y2;
      //Formula Section
      dy = Y2 - Y1;
      dx = X2 - X1;
      slope = dy/dx;
      if (slope < 1)
      cout<<"Line will travel more along X-Axis and Less along Y-Axis";
      if (slope == 1)
      cout<<"Line will make the 45 degree angle with the horizon";
      if (slope > 1)
      cout<<"Line will travel more along Y-Axis and Less along X-Axis";
      if (dx == 0)
      cout<<" Line is parallel to Y-Axis";
      if (dy == 0)
      cout<<" Line is parallel to X-Axis";
}




Look at this program :(
Last edited on
Well it should compile except you still hacent listened about dividing and the abs
But not compiling :( But y not compiling the Program ;;;
Like ne55 said probably pre 98 cmpiler try a different one or a newer ide wiith a newer compiler
I haven't any more copiler :(
Google.com
I am using windows8 ,so far i don't think Winodws8 read any old compiler and i using 5.1.0.0 the latest 6.1.0 not worked in Windowa8
Which ide? I don't know what. 5.1.0.0 is there are thousands of ides
Pages: 1234