Question

In: Computer Science

Explain why commenting code is important. Include an example of a good comment and of a...

Explain why commenting code is important. Include an example of a good comment and of a bad comment. This should be done with matlab in mind.

Solutions

Expert Solution

comment the code is very important thing.one who write the code easily understand but if otherperson also want to understand then we must write comments for well understand.

in generally if any software is developing lot of programmers working on the same project so they want share the same source based on the source code they will move forware so then kind of situations every one must know the logics of the code then they will use comments for other people want to understand.

bad comments in the sense no need to write every line as comment because then code looks not good then we must use comments very important things which as some logic is there.

good comments in the sense every important point must be commented then it was looks good

#sample code for good comment

#bad comment

here the condition was present at line to but the description of line is present in 6 so it was not good idea and not good comment.


Related Solutions

Give an example of a consumption good and an example of an investment good. Explain why...
Give an example of a consumption good and an example of an investment good. Explain why the two are different, as a macroeconomist would think of them differently. Also, explain why investment is important for the long term health of an economy.
1)Comment on the importance why understands that good management of the capital budget is important for...
1)Comment on the importance why understands that good management of the capital budget is important for a company. 2)Discuss about the concept of structure of capital and its importance. Look for an example of a company and how manage its capital structure.
Is the study a good example of the scientific method? Explain why or why not. Make...
Is the study a good example of the scientific method? Explain why or why not. Make sure you think about what makes for a legitimately good use of the scientific method, especially when it comes to experiments on humans. Do not simply use your opinion here. Read over scientific method in your book and notes!!! 2. Is there a correlation (legitimate connection) between autism and vaccines based on this study? Explain why or why not. 3. Is there a correlation...
Why are cash budgets important in business? explain with example.
Why are cash budgets important in business? explain with example.
C++ code Why my code is not compiling? :( #include <iostream> #include <iomanip> #include <string> using...
C++ code Why my code is not compiling? :( #include <iostream> #include <iomanip> #include <string> using namespace std; const int CWIDTH = 26; int main() {    int choice;    double convertFoC, converCtoF;    double starting, endvalue, incrementvalue;    const int CWIDTH = 13;    do {       cin >> choice;    switch (choice)    {        cin >> starting;    if (starting == 28){       cout << "Invalid range. Try again.";    }    while (!(cin >> starting)){       string  garbage;       cin.clear();       getline(cin, garbage);       cout << "Invalid data Type, must be a number....
6. Explain why it is so important for a company to have good forecast in the...
6. Explain why it is so important for a company to have good forecast in the future. 7. Explain the term “ Depreciation is a NON cash expense” and how do company’s use it. 8. List a few advantages and disadvantages for opening up a company as a corporation.
Explain why is euler theory good mathematically but not equally good mechanically. Give one example to...
Explain why is euler theory good mathematically but not equally good mechanically. Give one example to prove your point.
Is it more important to speak well, or to listen well? Explain why, and include at...
Is it more important to speak well, or to listen well? Explain why, and include at two strategies or examples to support your response
Give an example of a monopoly. Explain why you think it is bad and/or good for...
Give an example of a monopoly. Explain why you think it is bad and/or good for the consumers.
Write the following program in java please. a. Include a good comment when you write the...
Write the following program in java please. a. Include a good comment when you write the method described below: Method method1 receives an integer, n, and a real number, d, and returns a real number. If the integer is positive it returns the square root of the real number added to the integer. If the integer is negative or zero it returns the absolute value of the integer multiplied by the real number. b. Write the statements from the main...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT