Find errors in C++.

Q32. Find errors, if any, in the following C++ statements:

  • int code = three //three is an enumerator.
  • enum(green, yellow, red);
  • const int size;
  • size = 10; //size is already defined constant;

Ans

(i). It is valid only when enumerations are treated as integers.

(ii). Wrong brackets. It should be:

enum{green, yellow, red};

(iii). Initialization not done. It should be const int size = 20;

(vi). No, we can’t assign a value to a constant variable.

Leave a Reply

Your email address will not be published. Required fields are marked *

98 Views
%d bloggers like this: