Non-primitive types are those defined by the programmer. They are also called reference types. In this article, you’ll learn the seven primitive types in C.

Integer Value Types

If you need to store an integer value in a variable, you can declare it as one of the following three types: int, short, or long.

The choice depends on how large you expect the integer value to be. For example, the int data type accepts four-byte values. Therefore, the range of values you give to it must be between -32768 and 32767.

It’s worth noting that long is a short form of long int, and short of short int.

C also provides for the long long data type, giving you even more memory space. The long long type has a range of -(2^63) to (2^63)-1. This data type can be very helpful when dealing with factorials.

You can also choose to have a larger positive range for your integral data type by qualifying it with the unsigned keyword. In that case, your range on the positive side is double that of its signed equivalent.

Floating Point Number Types

You may need to store fractional numbers. In this case, you’ll need to use the float and double types.

The float type specifies a range between 3.4e-038 to 3.4e+038, while double specifies a range between 1.7e-308 to 1.7e+308. The big difference is that double has twice as much decimal point precision as the float data type.

C also provides the long double extended type should you wish to use it.

See also: A Beginner’s Guide to Input and Output in C

Character Type

To store character values, you need to use the char data type. It stores one byte and has a range of -128 to 127.

Tips to Easily Learn C Programming

There’s no need for you to make the same avoidable mistakes that newbie programmers have made. Learning a new language, especially one like C, needs you to commit to it and be methodical.

Having a structured way of learning can greatly ease your programming journey. Begin with the basics such as variables, operators & standard libraries then gradually move on to topics like file handling. One step at a time does it.