Question #342880

Find the error(s) in each of the following program segments and explain how the error(s) can be corrected: 

(ii) int sum(int x, int y) { int result; result = x + y; }


Expert's answer

The error: you forgot to return the result

this should be like

int sum(int x, int y) { int result; result = x + y; return result; } or int sum(int x, int y) { return x + y; }


LATEST TUTORIALS
APPROVED BY CLIENTS