BlackBerry Interview Question

Write a function that will return x*7 without using multiplication?

Interview Answers

Anonymous

Jan 26, 2012

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

1

Anonymous

Jan 17, 2012

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