How do you write a single-line comment in C?

2015

How do you write a single-line comment in C?

Answer: C. // This is a commentTo write a single-line comment in C, use two forward slashes (//). Any text following // on the same line is treated as a comment and ignored by the compiler.

  1. A.

    /* This is a comment */

  2. B.

    # This is a comment

  3. C.

    // This is a comment

  4. D.

    -- This is a comment

Attempted by 3072 students.

Show answer & explanation

Correct answer: C

To write a single-line comment in C, use two forward slashes (//). Any text following // on the same line is treated as a comment and ignored by the compiler.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…