Getting Started
...
Glossary
N-Z Terms
Variable
4min
a variable in computer programming is a named location in memory where data can be stored variables are used to store information that is needed by a program for example, a variable can be used to store the player's score in a game or the current temperature in a weather forecast variables are created using a variable declaration statement the general syntax for a variable declaration statement is variable type variable name; where variable type is the type of data that the variable will store, and variable name is the name of the variable for example, the following statement declares a variable called score that will store an integer int score; once a variable has been declared, it can be used to store data using an assignment statement the general syntax for an assignment statement is variable name = expression; where expression is an expression that evaluates to a value of the same type as variable name for example, the following statement assigns the value 10 to the variable score score = 10; variables can be used to store data of any type, including integers, floating point numbers, strings, and boolean values the type of data that a variable can store is determined by the variable's type for example, the variable score can only store an integer value, while the variable name can store a string value variables can be used to store data that is needed by a program for example, a variable can be used to store the player's score in a game or the current temperature in a weather forecast variables can also be used to store temporary data that is used by a program for example, a variable can be used to store the result of a calculation that is needed by the rest of the program feedback please be sure to submit issues or feature requests through the embedded feedback form in the event it is a major issue please contact us directly through discord