Programming Concepts Tutorial

Learn the fundamental concepts of computer programming

Variables

Variables

A variable is a named container used to store data in a computer's memory. Think of it as a box with a label on it.

Declaring a Variable

When you create a variable, you are declaring it. When you give it data, you are assigning a value to it.

Rules for Naming Variables

  • Names should be descriptive (e.g., score instead of s).
  • Cannot contain spaces.
  • Cannot start with a number.

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics