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; }
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; }
Comments
Leave a comment