Ask your own question, for FREE!
Computer Science 22 Online
OpenStudy (anonymous):

calculate the value corresponding to the following formula in its own module: 2 * num1 + 4 * num2 + num1 * num2 - num1 / num2 // int division and this module *must* match the following prototype: int algebra(int num1, int num2); where num1 is x and num2 is y.

OpenStudy (anonymous):

This is the only part of my code I can't get to work. So far I have... int algebra(int num1, int num2); { int x, y; x = (double)num1; y = (double)num2; algebra = 2 * x + 4 * y + x * y - x / y; } and it does not work.

OpenStudy (rsmith6559):

algebra (in the assignment statement) isn't declared and it will be type double. If you want to do integer division, and return an integer (BTW, algebra is probably your return statement) why are you casting x, y to double?

OpenStudy (anonymous):

int algebra(int num1, num2) { return 2 * num1 + 4 * num2 + num1 * num2 - num1 / num2; } You shouldn't have a semicolon after declaring the function inline: "int algebra(int num1, num2); {" Is not valid code. You shouldn't be casting to double. You always need to explicitly "return" at the end, unless the function is void. You can't assign "algebra" to be an int; it is the name of the function.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!