Zebra0

Learn to Program Step-by-Step

C++ Variables: type

C++ Variables: type

Before a variable can be used, it must be declared. To declare a variable, first decide what type of information you want to store.

Basic Types

Whole numbers, number with no decimal places are called int (integers.)
Numbers with decimal places and very large numbers are called double.
Single letters such as ‘Y’ or ‘N’ are CHAR (characters.)
Words, such as “Hello”, or a persons name are called strings.
Variables that can only have the values true or false are called bool (Boolean.)
Strings are somewhat more complicated because they require an array of memory locations. Strings are discussed in another lesson.

In addition to the basic types, variables can also be declared as one of the classes:
// This will make the background of the form blue.
Color myFav = Color.Blue;
BackColor = myFav;


Drill on type

Like us on Facebook:


OER: Open Educational Resource
Creative Commons License Author: Janet E. Joy; Publisher: Zebra0.com
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
Creative Commons Attribution-NonCommercial 4.0 International License
Last modified: January 24 2018 10:14:22.