You are on page 1of 2

Experiment 6

AIM: -​ ​To​ ​calculate lines of code of software


Theory​: -
Estimation of the size of software is an essential part of Software Project Management. It helps
the project manager to further predict the effort and time which will be needed to build the
project. Various measures are used in project size estimation.
Lines of code is one of the methods to calculate project size.
As the name suggest Lines of code is simply the no of lines of source code in the software
project. While calculating the line of code in the project we have to exclude commit lines and
blank lines as they will not contribute in program and developer can misuse it.

Advantages​:
● Universally accepted and is used in many models like COCOMO.
● Estimation is closer to developer’s perspective.

Disadvantages​:
● Different programming languages contains different number of lines.
● No proper industry standards exist for this technique.
● It is difficult to estimate the size using this technique in early stages of the project.

Program to calculate lines of code


#include<stdio.h>
int main()
{
int line_count=0;
char ch;
FILE *fp1;
fp1 = fopen("/home/vinamra/Desktop/2cpp/segTree/xeniaandbits.cpp", "r");
if(fp1==NULL)
{
printf("Could not open file %s\n","xeniaandbits" );
return 0;
}
while ((ch = fgetc(fp1))!= EOF)
{
if (ch == '\n')
{
line_count++;
}
}
printf("Total no of lines: %d\n", line_count);
return 1;
}

Output :-

Conclusion
Through this experiment, we learnt how to calculate lines of code in software.

You might also like