1

I have the following code:

  z=x-~y-1;
    printf("%d",z);
  z=(x^y)+2(x&y);
    printf("%d",z);
  z=(x|y)+(x&y);
    printf("%d",z);
  z=2(x|y)-(x^y);
    printf("%d",z);

I get this error message:

10:11: error: called object is not a function or function pointer 
z=(x^y)+2(x&y); 
        ^ 

The language is C. Why did this happen?

3
  • 1
    What is 2(x&y) supposed to do? Commented Mar 2, 2017 at 15:53
  • 5
    change to 2*(x&y) Commented Mar 2, 2017 at 15:55
  • Oh Thx a lot!!! Commented Mar 2, 2017 at 15:56

2 Answers 2

1

As for what the error means: 2(x&y) tells the compiler to call the function 2, passing x&y as an argument (just like printf("hi") means "call printf and pass "hi" as an argument").

But 2 isn't a function, so you get a type error. Syntactically speaking, whenever you have a value followed by (, that's a function call.

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

Comments

1

Change

z=(x^y)+2(x&y);

to

z=(x^y)+2*(x&y);

and

z=2(x|y)-(x^y);

to

z=2*(x|y)-(x^y);

You need the multiplication operator if multiplication is what you intended.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.