Skip to main content

Comments in Programming Language




A comment is a piece of descriptive text which explains some aspect of a program. Program comments are totally ignored by the compiler and are only intended for human readers.

C++ provides two types of comment delimiters:

· Anything after // (until the end of the line on which it appears) is considered a comment.
· Anything enclosed by the pair /* and */ is considered a comment.

Comments should be used to enhance (not to hinder) the readability of a program.

The following two points, in particular, should be noted:

· A comment should be easier to read and understand than the code which it tries to explain. A confusing or unnecessarily-complex comment is worse han
no comment at all.
· Over-use of comments can lead to even less readability. A program which contains so much comment that you can hardly see the code can by no means be considered readable.
· Use of descriptive names for variables and other entities in a program, and proper indentation of the code can reduce the need for using comments. The best guideline for how to use comments is to simply apply common sense.

Comments

Popular posts from this blog

Object-Oriented Programming and JAVA Programming Language

  Object-Oriented Programming and:   Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction, encapsulation, messaging, modularity, olymorphism, and inheritance. Many modern programming languages now support OOP, at least as an option. JAVA Programming Language: Object-oriented programming is at the core of Java. In fact, all Java programs are object-oriented, this isn’t an option the way that it is in C++, for example. OOP is so integral to Java that you must understand its basic principles before you can write even simple Java programs. Therefore, this chapter begins with a discussion of the theoretical aspects of OOP.

Compilation Process of a C++ Program

Compiling a C++ program involves a number of steps (most of which are transparent to the user): · First, the C++ preprocessor goes over the program text and carries out theinstructions specified by the preprocessor directives (e.g., #include ). The result is a modified program text which no longer contains any directives. · Then, the C++ compiler translates the program code. The compiler may be a true C++ compiler which generates native (assembly or machine) code, or just a translator which translates the code into C. In the latter case, the resulting C code is then passed through a C compiler to produce native object code. In either case, the outcome may be incomplete due to the program referring to library routines which are not defined as a part of the program. For example, Listing 1.1 refers to the << operator which is actually defined in a separate IO library. · Finally, the linker completes the object code by linking it with the object code of any lib...

DIFFERENCE BETWEEN IDENTIFIER AND KEYWORD

Identifier keyword Identifiers are names that are given to various program elements, such as variable, function and arrays. C take some reserved word called keyword, they have predefine meaning in C. Identifiers consist of letters and digits. Keyword consist only letter. Identifier’s first character must be a letter. Keyword’s all character is letter. Identifiers Upper and lowercase letter is use. Keywords are all lowercase. Upper and lowercase are not equivalent. Upper and lowercase are also not equivalent. Like: X, sum_5, _weather etc. But 4 th is not identifier cause identifier first character must a letter. Like: auto, short, long etc.