Interview Question

Interview Ottawa, ON (Canada)

Write a function that will return x*7 without using

  multiplication?
Answer

Interview Answer

2 Answers

0

int func(int x) { return (x<3)-x; }

Interview Candidate on Jan 16, 2012
1

You could either do this by macro or inline (it usually would be inlined). inline int mulby7(int x) { return (x << 3) - x; }

I.S on Jan 26, 2012

Add Answers or Comments

To comment on this, Sign In or Sign Up.