answersLogoWhite

0


Best Answer

C uses two types of comment: single-line and multi-line. The multi-line comment originated in C while the single-line comment originated in C++. Both types are supported by both languages today.

A single-line comment begins with the double-slash token (//) and extends to the end of the line.

A multi-line comment begins with the slash-asterisk token (/*) and ends with the asterisk-slash token (*/).

Examples:

int x; // this is a single-line comment

/* this is multi-line comment, typically

used to introduce a function or class */

Note that since multi-line comments are fully-delimited, they may be used within the middle of a line of code. This is most useful when a function is forward-declared with a default value for one of its arguments and you wish to include that default value in the function definition (something which is not permitted under the one-definition rule):

void f (int = 0); // declaration

void f (int x /* = 0 */) { // definition

}

Such usage is really only of use to the function maintainer, as a reminder that the function has a default value.

We can also use this technique when a function has an argument that is reserved for future use, but is otherwise unused in the current version of the function:

void g (int); // declaration

void g (int /* unused */) { // definition

}

Again, such usage is only of use to the function maintainer.

User Avatar

Wiki User

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

Wiki User

8y ago

C supports two comment types: single-line and multi-line. The single-line comment was inherited from C++.

// this is a single-line comment: it extends to the end of the line

/* this is a multi-line comment:

it extends until the end-of-comment marker */

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

The two types of comment in C Programming are: In-Line Comment and Block Comment.

In-Line Comment (denoted by double slash //) is use to add comment for a specific line only. Codes that will come after these double slash will be treated as a comment and will not actually read by the program.

Block Comment (denoted by slash-asterisk and asterisk-slash /* */) is use to add comment in a block style. Anything that is inside the block comment will be treated as a comment, no matter how many lines it takes. Unlike the In-line comment, codes after the asterisk-slash (*/) will be treated as codes and will be read by the compiler.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the two types of comments in c programming language and how do they differ?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the range of data types in C programming language?

The ranges for all data types in C are implementation-defined.


Why do you need two types of coding in one programming language?

It would be easier to answer, if you explained what the 'two types of coding' were.


What are the types of Processor faults in c?

Processor faults are not related with a specific programming language.


What are the different types in java programming language?

core java ,jse.advanced jse,jee and j2me


What are the three types of language?

There are more than 3 types of programming languages. Check similar questions/answers before posting this.


Which is the best website for practicing programming?

w3schools has many tutorials for many different types of web programming language. breakinterview.com has some good questions for practice .


What types of programming languages have the most instruction explosion?

Programming languages differ in the degree of instruction explosion. Even different types of statements within a language vary in the degree of instruction explosion. In general, statements describing mathematical computation have low instruction explosion (10:1 or less), while statements describing I/O operation have high instruction explosion (100:1 or more).


Applets are written in what programming language?

There are many types of applets, and they can be written in many different languages, but you're probably referring to the most widely known Java applets. So, they're written in a programming language called Java.


2 types of identifiers in C programming language?

1. identifiers beginning with a letter 2. identifiers beginning with an underscore


How does an idiom differ from other types of figurative language?

Idioms cannot be figured out by defining the terms literally.


What is the purpose of having more than one programming language?

No programming language is perfect. Each one tends to excel at solving one or more types of problem, but is unsuitable for other problems. We have many languages so that we can pick a language which is suitable for the particular problem we're facing.


What is the classifications of programming languages?

There are only 2 types of language - 1. High level:- All language which we are using comes in this category. 2. Low level:- This are the language which is used for system programing.