Notice: Undefined offset: 14191426 in /var/www/html/qa-external/qa-external-users.php on line 744

Notice: Undefined offset: 13725163 in /var/www/html/qa-external/qa-external-users.php on line 744

Notice: Undefined offset: 14687412 in /var/www/html/qa-external/qa-external-users.php on line 744

Notice: Undefined offset: 13777325 in /var/www/html/qa-external/qa-external-users.php on line 744
What is role of comments - OnlineGDB Q&A
Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

closed What is role of comments

+34 votes
asked Jan 9, 2025 by hamza tahir (250 points)
closed May 17, 2025 by Admin
closed with the note: answered

19 Answers

+9 votes
answered Jan 9, 2025 by SHREE RAM (320 points)
Comments are used to give a context to the reader of the code that what is the code about.
+2 votes
answered Jan 17, 2025 by Sandeep Gupta (180 points)
Comments are completely ignored by the compiler. They are used by the code-reader(human) to understand the concept/syntax of the code.
+2 votes
answered Jan 23, 2025 by Adam Smith (180 points)
Comments in Code is very helpful specially when you are working on big projects then before every section of code you can write a Line in your own language even and mention what about this code actually and what's doing here. So, In future it will be easy for you to update this code easily.
+1 vote
answered Jan 25, 2025 by Ku2407u278 Diya Chauhan (160 points)

Comments are used to give a context to the reader of the code that what is the code about.

+1 vote
answered Jan 26, 2025 by Minu Mohan (160 points)
Comments are often recommended when the code is specific to some particular business logic , or maybe complex that just by seeing the code someone else cannot understand it completely. It  can help to give more context on the code to a third person looking into code.

In general it is recommended to make code simple enough to understand and maintained by anyone in future without the need of additional comments added. But in specific cases we tend to write code which deviate from normal flows or add more complexity to the code, where comments can help a new developer to understand and maintain it. On a lighter note i have seen code comments like " god know why this is added" :)
+2 votes
answered Jan 27, 2025 by (180 points)
comments are used to understand the executer what information are they giving. But, in some most of the cases they used to print the content/code .
+1 vote
answered Jan 28, 2025 by (160 points)
Comments are explanatory statements that help the reader in understanding source code. They can be entered at any location in the program. They are ignored during program execution which means they are
not executable statements.
+1 vote
answered Jan 31, 2025 by VYAS VED HIMANSHU _185 (200 points)
when someone refers your code or even you refer your code again after long time it becomes easy to understand and you can differentiate block of code accordingly
+2 votes
answered Feb 1, 2025 by saad shah (180 points)
Better understanding of code and structure of programing.
+1 vote
answered Feb 7, 2025 by gordd (260 points)
Comments should identify the "why" of a design decision's code--never the "what".

Some pre-processing tools, such as doxygen or a code verification scanner, actually need directions "hidden" in comments so that the language compiler won't notice them.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...