Challenger App

No.1 PSC Learning App

1M+ Downloads
Which of the following is not a correct C++ comment ?

A/*comment*/

B/*comment*\\

C//'comment*/

D/*//comment/*/

Answer:

B. /*comment*\\

Read Explanation:

C++ Comment Syntax Overview

  • Single-line comments: Represented by //. Any text following this marker on the same line is ignored by the compiler.
  • Multi-line (Block) comments: Represented by /* ... */. Everything placed between these delimiters is treated as a comment, allowing for documentation that spans multiple lines or portions of a line.

Key Rules and Constraints

  1. Nested Comments: C++ does not support nested block comments. Attempting to wrap a block comment within another (e.g., /* /* ... */ */) will result in a compilation error because the compiler interprets the first */ as the end of the entire comment block.
  2. Invalid Syntax: Using syntax markers incorrectly, such as mixing styles or omitting delimiters, leads to syntax errors. For example, using // to start a multi-line block without repeating the marker on each line or attempting to use invalid characters within the comment markers is prohibited.
  3. Compiler Behavior: Comments are treated as white space by the C++ preprocessor and are completely removed before the compilation process begins.
  4. Best Practices: While // is widely used for brief descriptions, /* */ is often preferred for temporarily commenting out large segments of code during debugging.

Related Questions:

ഒരു C++ ക്ലാസിലെ അംഗ ഫംഗ്‌ഷനുകളെക്കുറിച്ച് ഇനിപ്പറയുന്ന പ്രസ്താവനകളിൽ ഏതാണ് /ശരി?

(i)ഒരു അംഗ ഫംഗ്‌ഷൻ ക്ലാസിന് പുറത്ത് മാത്രമേ നിർവചിക്കൂ

(ii)ക്ലാസിന് സമാനമായ പേരുള്ള ഒരു അംഗ ഫംഗ്‌ഷനെ കൺസ്ട്രക്റ്റർ എന്ന് വിളിക്കുന്നു .

(iii) ക്ലാസ് ഡാറ്റയിൽ ഒരു അംഗ ഫംഗ്ഷൻ പ്രവർത്തിക്കുന്നു

Which is not a Unicode encoding form?
Which of the following is a programming Language ?
What is the correct JavaScript syntax to write "Hello World"?
Which of the following is a computer code ?