This shows you the differences between two versions of the page.
|
cpp:variables [2014/02/08 00:09] 173.69.2.138 |
cpp:variables [2024/02/16 00:48] (current) |
||
|---|---|---|---|
| Line 4: | Line 4: | ||
| To create a variable: | To create a variable: | ||
| - | <code> | + | <code cpp> |
| //don't worry about things that have a " * " in the comment, we'll get to those | //don't worry about things that have a " * " in the comment, we'll get to those | ||
| Line 28: | Line 28: | ||
| This is a list of the most common types of variables: | This is a list of the most common types of variables: | ||
| - | <code> | + | <code cpp> |
| bool Stores either value true or false. | bool Stores either value true or false. | ||
| char Typically a single octet(one byte). This is an integer type. (one character) | char Typically a single octet(one byte). This is an integer type. (one character) | ||
| Line 41: | Line 41: | ||
| Our variable was an "int" or, in Enlish, an integer. Let's make the variable equal to a number. | Our variable was an "int" or, in Enlish, an integer. Let's make the variable equal to a number. | ||
| - | <code> | + | <code cpp> |
| int var1 ; | int var1 ; | ||
| var1 = 5 ; | var1 = 5 ; | ||
| Line 51: | Line 51: | ||
| Variables can even be equal to each other! | Variables can even be equal to each other! | ||
| - | <code> | + | <code cpp> |
| - | int var1 = 5 ; | + | int var1 = 6 ; |
| int var2 ; //another integer variable named "var2" | int var2 ; //another integer variable named "var2" | ||
| var2 = var1 ; //the value of var2 is now the same as the value of var1 | var2 = var1 ; //the value of var2 is now the same as the value of var1 | ||