• In computer programming, you often hear or read references to values being assigned to variables, or declaring variables, or initializing variables. What are variables?

    What is a Variable?

    The word variable means "changeable." In computer science, variables refer to information, stored in memory, that can be changed as a program runs.


    This is opposed to constants, a word that means "doesn't change." In computer science, constants refer to information stored in memory that are not allowed to change during runtime. They usually represent information like the mathematical constant pi.

    Variable Scope

    An important concept in programming is variable scope. In most languages, a given variable will have a scope, or a section of the program, within which a given variable can be used, and outside of which it is invalid and cannot be used.


    In most languages, variables have a type that refers to what kind of information they can store. Examples include integer (for whole numbers), float (for numbers that include a decimal place), and characters (for letters).

    Static Variable Typing

    Most languages, including C and Java, use static variable typing. This means that once a variable has been declared in a scope to have a certain type, the compiler checks to ensure that it uses only that type from then on within that scope.

    Dynamic Variable Typing

    A few other languages, such as Python, use dynamic typing, where the type is stored with the data in memory.


    What is variable?

    CS, Scope, and Advanced Conditionals

    Variable Types

Copyright 2018, Wired Ivy, LLC

Answerbag | Terms of Service | Privacy Policy