a) INT
b) my-name
c) your_name
d) $dollar
e) stock Price
f) _UnitPrice
g) while
h) 1$dollar
i) switch
j) whileYou
k) ifYou
l) if
m) int
n) int34
o) ab.3c
p) ab_3c
q) 4%6
r) fourTimesSix
s) 4 * 6
t) apples3

Dani AI

Generated

Quick answer for : the definitely invalid identifiers from your list are

b) my-name (hyphen),
e) stock Price (space),
g) while (reserved keyword),
h) 1$dollar (starts with digit and contains $),
i) switch (reserved keyword),
l) if (reserved keyword),
m) int (reserved keyword),
o) ab.3c (dot),
q) 4%6 (percent sign and starts with digit),
s) 4 * 6 (spaces and *).

Two important clarifications: d) $dollar is implementation-dependent — many compilers accept $ but the C++ standard does not require it, so avoid $ for portable code. f) _UnitPrice is syntactically allowed but falls into the category of names reserved for the implementation (identifiers beginning with an underscore followed by an uppercase letter, or those containing a double underscore, are reserved) and should be avoided in user code.

Why: standard identifiers must start with a letter or underscore and may contain letters, digits, and underscores; keywords cannot be used as identifiers; punctuation, spaces and operators are not allowed. See the language reference on identifiers and the keyword list for the full rules: Identifiers and C++ keywords.

Practical tip: use camelCase or snake_case, start names with a lowercase letter, avoid leading underscores (especially followed by uppercase), and keep identifiers to letters/digits/underscore for the best portability. ’s MSDN pointer is useful, but the linked cppreference pages above give the standard behavior and reserved-name details.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.