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

0 votes
answered Feb 9, 2025 by Tobscode (140 points)
Comment are used to give predictions or information of what are about to program or code.
0 votes
answered Feb 10, 2025 by Ghatkari Sampath (150 points)
Comments are used to provide information about the code and for better understanding of the code.
0 votes
answered Feb 12, 2025 by Yassire Daniel Allaoui (140 points)

A comment in code is used to explain or clarify specific parts of the program, without affecting the execution of the code itself. In other words, comments are there to help developers (or anyone else reading the code) understand what the code does and why it is written in that particular way.

0 votes
answered Feb 12, 2025 by (240 points)
role of comments:

comments are usually at the top of the program to give  a context about the code which you have written

for example if you are writinga  code about palindrome you an write it as

//palindrome code(which is a single line comment)

you can also write in the middle of the code to understand every line clealy

they are two types

single line comments://...........

multi line comments:/*..............*/
0 votes
answered Feb 14, 2025 by prem vadikari (250 points)

the role of comments in the program

as the small codes does not need codes but if the codes above 100 lines are we cant get what is about so to understand esaily why the step is taken by programeer so we are use comments

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

0 votes
answered Feb 24, 2025 by TransCode (330 points)
In code, comments are used to explain your code, whether that be the logic, some notes as to the functionality, or anything else of importance. Many coding languages, including Java, JavaScript, and many more, allow you to make comments by putting "//" in front of some text. Take for example, this Java program:

public class Main {
    public static void main(String[] args) {
        System.out.println("This is code that's actually being run, comments are ignored by compilers and  interpreters.");
        // This is a comment!
    }
}

In Python, comments are achieved by using an octothorpe, (aka the hashtag), like this:

print("This code is going to be interpreted.")
#This comment will be ignored by the interpreter.

I hope this helps! If you have other questions regarding comments, feel free to ask.

Have a wonderful day,
    -TransCode
0 votes
answered Feb 24, 2025 by Shubham Kumar Gupta (140 points)
Comments are usually any information given by programmers to the reader for better understanding. These are mostly used by programmers who want to make their program clean, understandable and professional.
0 votes
answered Feb 25, 2025 by Federico Vanoli (140 points)

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

0 votes
answered May 5, 2025 by Afia Raymond (350 points)
comments are notes you can give to ur self as a reminder to do something or add
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.
...