• No products in the cart.

Data Types Programming C++ (video)

In this article, we will refer to the console program written in the C ++ programming language. A user interacts with a console program using a keyboard and a display screen. The data is sent from the program to instructions, this data is called input data. The data generated by processing the input data is called intermediate data. The program’s instructions therefore process the intermediate data and this will lead to the output data.  Output data is displayed on the output console.

I. We have a first data classification:

  • input data
  • intermediate data
  • output data.

This classification helps us understand what instructions we apply to the data:

  • on input data we will apply the input instructions.
  • on output data we will apply the output instructions.


II. A second data classification refers to the memory space (implicitly or explicitly) for data used in a program.  In this case, data used in a program are:

  • values
  • constants
  • Values:

Thesis can be used in the processing of input data and no need explicit declaration.

Example: 0, 1, 10, 3, 9.

Values ​​can be:

  • Integer: (for example: 0, 10, -72, 94525) or Real (for example 3.14, -7.38).
  • Character: (for example: A, hyphen, star, 1). A character must be written between apostrophes.
  • A value can be a String: a Sequence of Characters between quotes.

Example: “Sequence of Characters”


These data can be used in program, but need explicit declaration. A constant may be declared using the const keyword and the syntax is:

const [Data Type] Constant Name = Value;

Data type is the supplied data type of the constant (int, long, char, float, etc.).

Example: const float pi equal 3.14;


const  pi equal 3.14;

It is possible to declare a constant without giving it a data type.

This line of code is reserved memory in RAM.  The memory location, where is the 3.14, can be referenced by the name pi.  During the program we will use the name pi when we need 3.14 value.

Memory location of constant is read only – the value can not be changed during the program.

Constant name:

The constant name may contain: alphanumeric characters, digits and underscore. A constant name can not start with a digit. Names are case sensitive.


Variables can be used in program, but they need explicit declaration to reserve memory. The syntax to declare a variable is:

Data Type Variable Name;

Data type may be a basic type: int, long, char, float, etc.

Variable names follow the same rules as constant name. Variable names may contain: alphanumeric characters, digits and underscore, they can not start with a digit, and variable names are case sensitive.

Example: long max1, Max1, max_1;

Max 1 with small letters is different from Max 1 with capital letter and both different from max underscore  1.

If we have the instruction:

max1 =10;

The declaration statement will reserve location in random-access memory. Then the value 10 is sent to location of variable max1. We may change the value of variable during the program.

Example: if we have max1 = max1 + 7;

Then, in max1 location we have value 10 plus 7, the result is 17 and the 17 value will send to location max1.

The last value is the current value of variable.

0 responses on "Data Types Programming C++ (video)"

Leave a Message

© 2017 e-IT-Learning. All rights reserved.