Data

The first thing you need to understand is that programs work with data. This can be data about the success of students in school, data about the activity on your Instagram page, character models for the game Fortnite, or data from nuclear submarine radars. Well, as you guessed - all these data are completely different.

There are several basic data types in the C language:

• int (integer numbers);
• float (floating-point numbers);
• char (characters).

Based on them, we will consider other data types later in our course.

Integer

The `int` data type works with integers. For example, you are doing accounting for a local firm, and according to your calculations, you should have \$235 in profit, but in reality - you have \$14 (you became a debtor).

Note

Float

This data type is used to work with non-integer numbers (when precision is required). For example, at the age of 10, buying three kilograms of ginger in the supermarket (confusing it with potatoes), you will see "2.89 kg" on the electronic scale. If we were to use the int type, the scale would display "2 kg". Agree, the difference is significant.

Char

This data type is used to store characters, but under the hood, it is an integer. Why is that? Because of ASCII. ASCII (American Standard Code for Information Interchange) is the system by which the char data type operates. For example, the number 100, when bound to the char data type, will turn into the letter `'d'`.

As we can see, the letter `'d'` corresponds to the number 100. And the number 51 corresponds to the character `'3'`, namely the character, not the number.

Note

ASCII is one of many codes. There are others, such as KOI8-U.

Data types are needed to work with the memory of your computer, or rather, what kind of information (what numbers) your program will process.

Everything was clear?

Section 2. Chapter 1