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

Created by Solid_Edge 

Upgrade to
remove ads

Creating a constant array. Wow, This set has my biggest flashcard yet!

{ 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.

Please allow access to your computer’s microphone to use Voice Recording.

Having trouble? Click here for help.

We can’t access your microphone!

Click the icon above to update your browser permissions above and try again

Example:

Reload the page to try again!

Reload

Press Cmd-0 to reset your zoom

Press Ctrl-0 to reset your zoom

It looks like your browser might be zoomed in or out. Your browser needs to be zoomed to a normal size to record audio.

Please upgrade Flash or install Chrome
to use Voice Recording.

For more help, see our troubleshooting page.

Your microphone is muted

For help fixing this issue, see this FAQ.

Star this term

You can study starred terms together

NEW! Voice Recording

Create Set