COMMON PROGRAMMING ERROR - FUNCTION

Here is a list of few common programming errors committed by us in function. For complete list of common programming errors visit : Common Programming Errors In C
  • Forget to put a semicolon at the end of prototype or function declaration.
  • Specifying function parameters of the same type as double x,y instead of double x, double y results in a compilation error.
  • Put a semicolon at the end of function header while defining the function.
         For example:
         float division(float a, int b);  // error
        {
              return a/b;
        }
  • Type mismatch error due to difference in the types in function declaration and function definition. The types of parameter may differ.
  • Type mismatch error due to difference in the order of parameters in function declaration and function definition.
  • Type mismatch error due to difference in the number of actual arguments and the number of formal arguments.
  • Defining a function inside another function is a syntax error.
  • Defining a local variable within a function with the same name as formal argument name.
         For example:
         float division(float a, int b)
        {
                  int a; //error defining the same variable
        }
  • Not returning any value when the function return type is not valid.
        For example:
        float division(float a, int b)
       {
              return ;
       }

Share this

Related Posts

Previous
Next Post »