![]() |
VOOZH | about |
A line of code (LOC) is any line of text in a code that is not a comment or blank line, and also header lines, in any case of the number of statements or fragments of statements on the line. LOC consists of all lines containing the declaration of any variable, and executable and non-executable statements.
Table of Content
As Lines of Code (LOC) only counts the volume of code, you can only use it to compare or estimate projects that use the same language and are coded using the same coding standards.
Lines of Code (LOC) measures the volume of code by counting all non-comment and non-blank lines, including variable declarations and statements. It helps track codebase growth and is easy to compute and understand. However, it does not reflect code complexity and is best used for comparing projects in the same language and coding standards. To explore more about LOC and its implications for software development, check out the Complete Guide to Software Testing & Automation by GeeksforGeeks , which covers various metrics and methods for assessing code and improving project outcomes.
Research has shown a rough correlation between LOC and the overall cost and length of developing a project/ product in Software Development and between LOC and the number of defects. This means the lower your LOC measurement is, the better off you probably are in the development of your product.
Let's take an example and check how the Line of code works in the simple sorting program given below:
So, now If LOC is simply a count of the number of lines then the above function shown contains 13 lines of code (LOC). But when comments and blank lines are ignored, the function shown above contains 12 lines of code (LOC) .
Let's take another example and check how does the Line of code work the given below:
Here also, If LOC is simply a count of the numbers of lines then the above function shown contains 11 lines of code (LOC). But when comments and blank lines are ignored, the function shown above contains 9 lines of code (LOC).