0

The question was Given three points (x1, y1), (x2, y2) and (x3, y3), write a program to check if all the three points fall on one straight line On compiling I'm getting the error called object " " is not a function or function pointer The program is as follows

#include <stdio.h>

int main()
{
    int sidex1,sidex2,sidex3,sidey1,sidey2,sidey3 ;
    printf("Type in the coordinates");
    scanf("%d%d %d%d %d%d", &sidex1, &sidey1, &sidex2, &sidey2, &sidex3, 
    &sidey3);
    if
    (sidex1(sidey2-sidey3)+sidex2(sidey3-sidey1)+sidex3(sidey1-sidey2)==0)
    printf("These coordinates lie on same line");
    else
    printf("These coordinates do not lie on a line");
    }

I'm a complete Noob. Thanks for Help!

4
  • 1
    What is sidex1(sidey2-sidey3) supposed to be? Commented Jul 9, 2018 at 16:18
  • 1
    So which line is giving the error? Commented Jul 9, 2018 at 16:18
  • You're using a variable of type int as a function pointer Commented Jul 9, 2018 at 16:19
  • Are you trying to multiply sidex1 by sidey2-sidey3? Commented Jul 9, 2018 at 16:20

1 Answer 1

5

To multiple variables in pretty much any program language, you use the * operator like this

sidex1*(sidey2-sidey3)

rather than what you have which is

sidex1(sidey2-sidey3)

which would be confused as calling a function called sidex1 with the parameter sidey2-sidey3

Sign up to request clarification or add additional context in comments.

2 Comments

Yep, I was missing the * but what do you mean by sidex1 with parameter sidey2-sidey3 that you stated
@NamanGupta The way you currently have things written, i.e. sidex1(sidey2-sidey3) makes it look like sidex1 is a function and sidey2-sidey3 is the parameter to that function. It's not a function, so that's why you got an error

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.