Valid declaration (C++)

Which of the following is not a valid deceleration?

A- unsigned float temperature;
B- int a, b, c;
C- char letter 5 65;
D- double mess;


I am stuck here, in terms of C++ programming, there are two answers in my view it is option A and D...

can anyone help me out to what is the right answer?
The answer is C.
char letter 5 65; is not a valid declaration, as you're not following correct syntax, and sprinkling random constants for no reason.
A declaration is just what its name implies : It declares something, in other words, something new has been introduced.
A declaration follows this syntax:

[type] [identifier];
Where 'type' is the data type of the variable, and 'identifier' is the name.

Note that a declaration is different from a definition. A definition defines what something is. A declaration merely states that something exists.

a = 10;//definition
Typically, when a variable is defined on the same line in which it is declared, one would say that it is being initialized.
int a = 10;//initialization
Last edited on
Topic archived. No new replies allowed.