C allows us to choose between several different options with our data types, since they are all stored on the computer in different ways. Therefore, it is important to be aware of the capabilities and limitations of each type of data in order to choose the most appropriate one. The actual size, as with all other types of C data, depends on the hardware you are working on. At least 8 bits, so you have at least 0 to 127. You can also use signed characters to get at least -128 to 127. As with all these other types of data, there is an unsigned variant that can be used. The unsigned int can be positive and null but not negative, so it can store values between 0 and 65,535 or higher, depending on the hardware. We can use the sizeof() operator to check the size of a variable. See the following C program to use the different types of data: In general, you should choose the minimum for your task. If you know you count whole numbers from 1 to 10, you don`t need a long one and you don`t need a double. If you know that you will never have negative values, you should use the unsigned variants of the data types. By providing this functionality, rather than doing it automatically, C is able to create very lightweight and efficient code. However, it is up to you, as a programmer, to understand the skills and limitations and choose accordingly.

A void* pointer represents the address of an object, but not its type. Example: a memory allocation function void *malloc( size size_t); Returns a pointer to void that can be converted to any data type. One quirk of C`s data types is that they depend entirely on the hardware on which you run your code. An int on your laptop is smaller than an int on a supercomputer, so it`s important to know the limitations of the hardware you`re working on. This is also the reason why data types are defined as minimums – an int value, as you will learn, is at least -32767 to 32767: on some computers it will be able to store even more values. There are several functions in C that do not accept any parameters. A function without parameters can take a void. Example: int rand(void); There are several ways to store data in C, and they are all unique from each other.

The types of data under which information can be stored are called data types. C is much less forgiving of data types than other languages. Therefore, it is important to make sure that you understand the types of data that exist, their capabilities, and limitations. The long data type is exaggerated for almost any application, but C allows you to use it anyway. It is capable of storing at least -9,223,372,036,854,775,807 to 9,223,372,036,854,775,807. Alternatively, you get even more overkill with unsigned long features, giving you at least 0 at 18,446,744,073,709,551,615. The amount of memory required by a single int depends on the hardware. However, you can assume that an int is at least 16 bits in size. This means that values between -32,768 and 32,767 or higher can be stored depending on the hardware.

The long data type stores integers like int, but provides a wider range of values at the expense of more memory. Long stores at least 32 bits, giving a range of -2,147,483,648 to 2,147,483,647. You can also use unsigned long for a range from 0 to 4,294,967,295. There are two categories that we can divide into two categories: integers and floating-point numbers. Integers are integers. They can be positive, negative or none. Numbers like -321, 497, 19345, and -976812 are all perfectly valid integers, but 4.5 is not, because 4.5 is not an integer. C chooses the type of data and allows us to be very precise and aware of how we do it.

This gives you a lot of power over your code, but it`s important to choose the right one. It`s not often used, but it`s good to know it exists. As int, it can store -32768 to 32767. However, unlike int, this is the extent of its capacity. Wherever you can use short, you can use int. long double takes at least 80 bits. As a result, we can get 19 decimal places from 3.4E-4932 to 1.1E + 4932. Double requires twice the memory of the float (i.e.

at least 64 bits). In turn, the double can provide 15 decimal places from 2.3E-308 to 1.7E+308. The void type indicates that no value is available. It is used in three types of situations: float requires at least 32 bits to store, but gives us 6 decimal places from 1.2E-38 to 3.4E + 38.