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

2015

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

  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 2056 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: Isro