Skip to main content

Coding Standards for C programming


 This document contains some of the coding standards that the students have to follow , when they
are writing the programs.

Indent style :


  • Indent the entire body of each function to one level of indentation.
  • Use three spaces or tab per level of indent.
  • Select the size of the indentation you prefer and uniformly apply that throughout the program.
                       
  • If there are several levels of indentation, each level should be intended the same additional amount of space.
  • Indent the statement/s in the body of an if statement
  • If a statement is split across two or more lines, indent all subsequent lines.
                       
  • Indent the statement/s in the body of an while/for statements.
                       

Comments:

  • Describe the purpose of each function in the program using a comment
  • Add a comment to the right brace } of every function, to indicate the end of function.
  • Add comments to describe the purpose of the statements in the program
      Example:
                         

Statements:

  • Separate the definitions and executable statements in a function with one blank line.
                           
  • Place a blank line before and after every if statement.
                         

White spaces:

  • Place a space after each comma(,) in printf and scanf statements.
                         
                          
  • Place space on either side of a operator
                         
  • Unary operators should be placed directly next to their operands with no intervening spaces.
                           

Naming conventions:

  • Choose meaningful variable name.
                           
  • When there are multiple words in a variable, begin each after the with a capital letter camel case (eg: totalCommissions)

Programming practices:

  • Try to avoid using more than three levels of nesting in loops.

Comments

  1. If you are looking for WHAT IS THE MEANING OF DIFFERENTIATION, go through this link
    https://mathsforit.blogspot.com/2019/11/what-is-meaning-of-differentiation.html?showComment=1595915476932#c6614167742183095589

    ReplyDelete

Post a Comment

Popular posts from this blog

මුදලේ කාර්යයන් - Functions of money - මුදල් හා මිල මට්ටම - econ (ආර්ථික විද්‍යාව) SL Education Tips

සිවිල් නීතිය හා අපරාධ නීතිය ගැන ඉගෙන ගමුද|ව්‍යාපාර නීතිය|ශ්‍රී ලංකාවේ නීතිය හා නෛතික රාමුව හැදින්වීම

ආර්ථික පද්ධති ගැන ඉගෙන ගමුද? - |ධනවාදී|සමාජවාදී|මිශ්‍ර| ආර්ථික ක්‍රම