Search This Blog

Loading...

how to write comment in c++ program

How to write comments in c / c++ programms ?
Analysis:The comments on lines 5 through 7 are completely ignored by the compiler, as are the comments on lines 9, 12, and 13.
The comment on line 9 ended with the end of the line, however, while the comments on lines 5 and 13 required a closing comment mark.

1: #include <iostream.h>
2:
3: int main()
4: {
5: /* this is a comment
6: and it extends until the closing
7: star-slash comment mark */
8: cout << "Hello World!\n";
9: // this comment ends at the end of the line
10: cout << "That comment ended!\n";
11:
12: // double slash comments can be alone on a line
13: /* as can slash-star comments */
14: return 0;
15: }

Output:
Hello World!
That comment ended!

No comments:

Post a Comment