Jump to content

Logic error

From Simple English Wikipedia, the free encyclopedia
Revision as of 11:11, 5 June 2017 by Rickyholding (talk | changes) (makes sense really)

DICKS FOR DAYYYS IN WIKI

Examples

This example function in C to calculate the average of two numbers contains a logic error. It is missing brackets in the calculation, so it compiles and runs but does not give the right answer.

int average(int a, int b)
{
    return a + b / 2;     /* should be (a + b) / 2 */
}