In: Computer Science
1 Commenting in C
There are two mechanisms in C to declare comments:
1. Commenting in a single line using // at the beginning, and
2. Commenting in potentially multiple lines using /* to mark the
beginning and */ to mark the ending.
For each of the following criteria, argue which commenting
mechanism is more preferred.
readability,
writability, and
reliability
1. Readability:
For this criteria single line commenting is more prefered because it exactly explains what the particular line or a block of code is doing and it is simple so becomes easier for another programmer to look into the code and understand the purpose of the each line in the code based on the comment.
for example:
// find marks in percentage
percentage =(marks_scored/total marks) *100
2. Writability:
for this criteria also single line commenting is more prefered because in this case it is easier to make changes in the comments later on if we have made any changes in the coding part.if we use multi line commenting then it becomes a bit difficult to make changes without the use of IDE's
3. Reliability:
Multiple line commenting should be used if we want to make our code more reliable because here we can explain the purpose of the code along of other details, so it becomes a bit easier to find out the errors in the code.By looking at the comment programmer will be able to understand the purpose of using a particular function or a block of statements and so he can find out what would have caused the error in the code