Extra parameter in call to function main

Hello,

I am consistently getting the error,
Extra parameter in call to LD() in function main()
If you could help me find my error, so I may fix it, it would be greatly appreciated.

*If you find other errors within my code, don't hesitate to point them out!

Thank you!
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <iostream.h>
#include <math.h>


   int LD (void);
   int SOL(int, int, int, int);

           
   void main()
           
   {
      double slope;
      float x1, y1, x2, y2;
      char ans;
      ans='y';
   
      while (ans=='y' || ans=='Y')
      {
         cout << "\nEnter X1: ";
         cin >> x1;
      
         cout << "\nEnter Y1: ";
         cin >> y1;
      
         cout << "\nEnter X2: ";
         cin >> x2;
      
         cout << "\nEnter Y2: ";
         cin >> y2;
      
         SOL (x1, x2, y1, y2);
         LD (x1, x2, slope);
      
         cout<<"\nDo you wish to continue? (y/n): ";
         cin>>ans;
      }
   }

           
   int SOL (int x1, int x2, int y1, int y2)
           
   {
      if (x1-x2 != 0)
      {
         cout<<"Slope is: "<<(y1-y2)/(x1-x2)<<endl;
         return (y1-y2)/(x1-x2);
      }
      else
      {
         cout<<"Slope is undefined.";
         return 0;
      }
   }

           
   void LD (int x1, int x2, int slope)
           
   {
      if (x1-x2 != 0)
      {
         if (slope > 0){
            cout<<"The line is: Rising";
         }
         else if (slope < 0){
            cout<<"The line is: Falling";
         }
         else if (slope == 0){
            cout<<"The line is: Horizontal";
         }
         else {
            cout<<"The line is: Vertical";
         }
      }
   }
Last edited on
Line 8: You define LD as not taking any arguments.
Line 32: You call LD with three arguments. This is inconsistent with the prototype at line 8.
Line 56: You implement LD with three arguments. This does not match the prototype at line 8. Your prototype and implementation must agree.
Line 8: You define LD as not taking any arguments.

Would I define LD the same way as I did to SOL?

Example:

void LD (int, int, int);
Last edited on
Yes.
Topic archived. No new replies allowed.