What is comment ? Explain why compilation is necessary before execution of a program ?

can ayone tell me what is comment and explain why compilation is necessary before execution of a program  in brief .

2 Answer

Comments are lines or sections of the program code that is not running. To explain the code, easier to read and provide notes for the future reference. Comments are ignored by compiler or translator.

// This is a single-line comment
/* This is a
   multi-line comment */

The compilation of the source code conversion process (written in a high -level programming language such as C, C ++ or Java) to the device code (binary code) is that the computer processor can understand and execute. Why the compilation  are required here are some point :

  • Translate to device code Computers cannot understand high -level languages.Collecting it to convert to car level instructions (0 and 1). Error detecti This compiler examines syntactic errors and more before executing. This prevents the implementation of the failed code. Optimization The compiler optimizes your code to improve performance and execute faster. Performance After the editing, this program runs faster than the interpreted code, because there is no need to translate during implementation.

In programming, a comment is a passage of text that is included into the code to describe its functionality and make it easier for the programmer or others to comprehend afterward. The compiler or interpreter ignores comments while the program is running, and they have no practical use. They are particularly helpful for pointing out errors or potential fixes, improving the readability of the code overall, and explaining the intent behind intricate code segments.

The process of turning developer-authored high-level programming code (like that written in C, C++, or Java) into machine code that a computer can comprehend and run is called compilation. Because computers run on binary machine code rather than immediately understanding high-level languages, this step is required. Program execution is impossible without compilation since the code cannot be converted into a format that the computer's processor can understand. Compilation serves as a link between machine-executable instructions and human-readable code.

#include int main() { // This is a comment: the next line prints "Hello, World!" to the screen printf("Hello, World!\n"); return 0; }

We use cookies to enhance your experience, to provide social media features and to analyse our traffic. By continuing to browse, you agree to our Privacy Policy.