Coding Standards for Writing Functions

Whether its C programming language or C++ programming language or PHP, we should have a coding standard in place before starting with the code development. Coding standard is a predefined standard which should be followed during the code development which will improve the quality of the code.

The coding standards varies from organization to organization. Each organization define their own coding standard and follow them to achieve the desired code quality.

Here, we will define a coding standard for writing functions.

Coding Standards for Writing Functions

  • A function name should be preceded by fn
  • The first character in the function name should be written in uppercase. Every subsequent word in the function name should start with an uppercase alphabet.

    Example:
    fnFactorial
    fnItemDisplay

  • The function should begin with a header which describes about the function. It is written as follows:
    /*****************************************************
    * Function:	fnFactorial()					
    * Description:	Accepts an integer and finds the                      
    *               factorial
    * Input Parameters: 
    *	int  - Number for which factorial to be found
    * Returns: int - Factorial of the given integer
    ****************************************************/
    
    int fnFactorial(int intNumber)
    {
       /*code to calculate factorial of a number*/
    }
    

You may also like...

1 Response

  1. March 17, 2014

    […] Also see: How does using functions make writing large programs easier? Coding Standards for Writing Functions […]

Leave a Reply

Your email address will not be published. Required fields are marked *

FREE C Cheatsheet - Speed Up Your C Programming.

FREE C Cheatsheet - Speed Up Your C Programming.

Download a 7-page free cheat sheet for easy and quick access to C Concepts, Snippets, and Syntax.

Thank you! Check you inbox and access your cheat-sheet