Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Specifying a Type | Introduction
C++ Data Types
course content

Зміст курсу

C++ Data Types

C++ Data Types

1. Introduction
2. Numerical Data Types
3. Text Data Type
4. Other Data Types and Concepts

book
Specifying a Type

Being a typed language means that you must declare the type of a variable when you initialize it. To specify the data type for the variable you have to use the following syntax:

By specifying the variable's data type, we inform the computer about the amount of memory needed to store its value and how to interpret that value.

What actually happens when we create a variable of some type

Let's look at the example of an int data type. As you will see in the next section, it requires 4 bytes (=32 bits) of data to hold its value. So, the computer must allocate 4 bytes of memory for storing this value.

The computer allocates 4 cells (bytes) of memory for the num variable. When we assign the value to a num, those cells will hold this value. Also, there is a memory address associated with the cells.

Values are stored in memory using a binary number system (sequence of 1s and 0s). So the numbers are being converted to a binary system first. The following video shows how the value of 1231 is stored in memory.

1. What does it mean for a language to be typed?
2. Which of the following is true about memory addresses?
What does it mean for a language to be typed?

What does it mean for a language to be typed?

Виберіть правильну відповідь

Which of the following is true about memory addresses?

Which of the following is true about memory addresses?

Виберіть правильну відповідь

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 5
We're sorry to hear that something went wrong. What happened?
some-alt