Machine-translated by Google. Questions are authored in English.
Top

Discussion

For which of the following, “PI++;” code will fail?

  • A.#define PI 3.14
  • B.char *PI = “A”;
  • C.float PI = 3.14;
  • D.Both (A) and (B)

Answer: A

Correct answer: #define PI 3.14

A #define is textual substitution, so PI++; expands to 3.14++; - and a constant is not an lvalue, so it cannot be incremented. The other two are variables: float PI can be incremented arithmetically, and char *PI can be incremented as a pointer.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.