How can we help?

You can also find more resources in our Help Center.

4 terms

C++ Programming in easy steps: Beginners 7 Part 3

Creating a constant array. Wow, This set has my biggest flashcard yet!
STUDY
PLAY
{ RED=1, YELLOW, GREEN, BROWN, BLUE, PINK, BLACK } ;
RED, YELLOW, GREEN, BROWN, BLUE, PINK, BLACK

Declare a statement to value each variable, starting from 1 and up.

This will be a constant declaration, because the elements
aren't going to change.

The statement begins simply by typing RED=1
And Inclosing them all in braces. (And a full-stop ; )

These are now "Constants".

The keyword "enum" will number each element in a concise manner. But they will always be surpassed, by the next one in line.

Because these constants need values starting from one and up, the "RED" (Being the first in the group) has it's value changed to a "1".
This changes all the values. Because every constant in the array, will surpass the one in front.

Note: The "enum" keyword, appears above the statement, but won't be included in this flashcards "term".
cout << "I shot a red, worth: " << RED << endl ;
Declare a statement that will output the following as text.
"I shot a red, worth: "

Use the constant called RED, in the statement.
This will output the constant value, alongside the text.
cout << "Then a blue, worth: " << BLUE << endl ;
Declare a statement that will output the following as text.
"Then a blue, worth: "

Use the constant called BLUE, in the statement.
This will output the constant value, alongside the text.
cout << "Total scored: " << ( RED + BLUE ) << endl ;
Declare a statement that will output the following as text.
"Total scored: "

Next, the constant RED and BLUE is enclosed within slashes, with the addition sign + between them.

Note: These spaces each have a character used.