Variables Recap

In this lesson we learned the basic concepts of working with variables in C++:

  1. Variables are used to store data in a program and we can change them at any time.
  2. Every variable must have a declared data type that determines what values it can contain.
  3. Basic data types are:
    • int for whole numbers
    • double and float for decimal numbers
    • char for individual characters
    • bool for boolean values
    • string for text
  4. We can declare and initialize a variable separately or at once.
  5. For printing variables we use std::cout and the << operator.
  6. Variable names must start with a letter or underscore and cannot contain spaces.

Instructions

Look at the sample code that demonstrates all the concepts we learned in this lesson. When you're ready, you can continue to the next lesson!

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

6/6

Variables Recap | Start Coder