Learn
Variables
Introduction to Variables

The "Hello World!" program simply writes to the screen. It does not read anything, calculate anything, or allow for user input. That’s no fun!

Real programs tend to produce results based on some input that the user of the program gives, rather than just outputting the same thing every time.

To read something from the keyboard, we first need somewhere in the computer’s memory to store data. That is where variables come in.

A variable is simply a name that represents a particular piece of your computer’s memory that has been set aside for you to store, retrieve, and use data.

In this lesson, we will learn about some of the basic data types:

  • int: integer numbers
  • double: floating-point numbers
  • char: individual characters
  • string: a sequence of characters
  • bool: true/false values

Every variable has a type, which represents the kind of information you can store inside of it. It tells your compiler how much memory to set aside for the variable, and it defines what you can do with the variable.

Instructions

Click Next to continue.

Folder Icon

Take this course for free

Already have an account?