answersLogoWhite

0


Best Answer

Preferably as little as possible, however it depends on the language. Low-level languages require a vast amount of user-comments because it can be extremely difficult to read the logic from the code alone. High-level languages require very few comments because the code should be largely self-documenting. Languages like C++ allow you to express concepts and ideas directly in code, so there's very little you need to document with a comment. Choosing good names for functions, classes and variables is a vital aspect of creating readable code.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

16y ago

To help the programmer keep track of what is going on. I start every new function I write by describing what I want to do in comments. Then, I fill in the gaps with executable lines of code to do what I described in the comments. Comments are useful in a team so that everyone understands what the function does. Not everyone on the team can read the code directly and know what it means, especially if it is complicated or subtle. Comments are also use to identify who wrote the function, or who made a particular change, so you know who to ask if you still don't know what the code does.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

A program is executed by the computer, and thus it DOES NOT include comments in those instructions.

Comments are for human eyes to understand a piece of code (a piece maybe range from 1 expression to the entire software). They should be saved with the code in files. Those files are NOT programs, they are simply text files.

A compiler or an interpreter takes those text files and translated into computer instructions to be carried out. The first thing to be removed from those text files - comments.

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

Comments are used to provide additional information to the (human) reader. C is a relatively low-level language and code can often be difficult to read, thus programmers use comments to provide more informative documentation within the code itself. In object oriented languages, the need for comments is greatly reduced because (most) notions can be expressed directly in the code itself. But in C, expressing notions in code is more difficult, thus comments help express these notions in natural language.

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

To explain why a piece of code exists. Even if you are the only developer who will ever see the code, simple reminders make code easier to digest, particularly when reviewing your old code. Good code requires very little commentary since it should be largely self-documenting. It is never necessary to explain what a piece of code does since the code itself tells you exactly what it does, but it won't necessarily tell you why it does it. Thus it helps to explain why a piece of code exists using a short introductory comment. Code that is verbosely commented is actually harder to read because it interrupts the flow of the code, therefore comments within the code itself should be placed off to one side.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Not mandatory.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

They are notes to a human reader.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

sdfgdsgv

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why do you need to use comments in a C program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are its program components?

the main() function,the#include Directive, the variable definition. function prototype, program statements, the function definition,program comments and braces are the components of program in C++


How can you add a comment in a JavaScript?

Javascript uses C-style comments, for block comments (multiline) use: /* comments go anywhere in here */ for short one line comments use double-slash: // this is also a comment


What is comment in c programming?

COMMENT:- comment a re not necessary in the program. however, to understand the flow of programs the programmer can include comments in the program. comment are to be inserted by the programmer. It is useful for documentation.Comment are nothing but some kind of statements which are placed between the delimiters /* & */. The compiler does not execute comments. Thus, we can say that comments are not the part of executable program.The user can frequently use any number of comments that can be placed any where in the program. Please note that the comments and statements can be nested. The user should select the OPTION MENU of the editor and select the COMPILER - SOURCE -NESTED COMMENTS ON/OFF). The Comments can be inserted with a single statement or in nested statement.Types of comment in c/c++. is following bellow1. // this is a single line comment2. /* */ this sing is multi line OR nested line commentseg. /* int i=90;char ch=65; */ close multi line commentsmade by [ARUN KUMAR RAI]


Dry run table in flow-chart?

/* my second program in C++ with more comments */ #include <iostream> using namespace std; int main () { cout << "Hello World! "; // prints Hello World! cout << "I'm a C++ program"; // prints I'm a C++ program return 0; }


What is the use of extend in c program?

Nothing.

Related questions

How do you remove comment from c program?

There are no comments in C programs. Comments only exist in the source code and the precompiler automatically strips them out before the compiler sees them.


Can comments be longer than one line and if yes how?

C++ also supports C program's multiple command line /* your command */.


What are its program components?

the main() function,the#include Directive, the variable definition. function prototype, program statements, the function definition,program comments and braces are the components of program in C++


How can you add a comment in a JavaScript?

Javascript uses C-style comments, for block comments (multiline) use: /* comments go anywhere in here */ for short one line comments use double-slash: // this is also a comment


Do you need Microsoft c plus plus redistributable?

If you use microsoft's "Visual C++ Compiler" whoever is going to use your program needs the redistributable installed.


What is comment in c programming?

COMMENT:- comment a re not necessary in the program. however, to understand the flow of programs the programmer can include comments in the program. comment are to be inserted by the programmer. It is useful for documentation.Comment are nothing but some kind of statements which are placed between the delimiters /* & */. The compiler does not execute comments. Thus, we can say that comments are not the part of executable program.The user can frequently use any number of comments that can be placed any where in the program. Please note that the comments and statements can be nested. The user should select the OPTION MENU of the editor and select the COMPILER - SOURCE -NESTED COMMENTS ON/OFF). The Comments can be inserted with a single statement or in nested statement.Types of comment in c/c++. is following bellow1. // this is a single line comment2. /* */ this sing is multi line OR nested line commentseg. /* int i=90;char ch=65; */ close multi line commentsmade by [ARUN KUMAR RAI]


Dry run table in flow-chart?

/* my second program in C++ with more comments */ #include <iostream> using namespace std; int main () { cout << "Hello World! "; // prints Hello World! cout << "I'm a C++ program"; // prints I'm a C++ program return 0; }


What C program for display in triangle?

Please visit http://talentsealed.blogspot.com/2009/10/to-display-triangle-using-c-programming.html for the answer. Please let me know your comments


Why we need function in c?

To break up the program into smaller pieces to help us understand the use of a function.


What translator is needed for C programming language?

To translate the C source code program, you need a program called a "C compiler".


How do you write a program in embedded c?

Use a text-editor program.


Why do programmers add comments to their code even though the computer itself ignores them?

The comments are there to (a) aid in debugging the program, (b) help the programmer layout the program in logical steps and (c) show anyone else looking at the code to see what each section of the code actually does.