top of page
Writer's pictureTechnology addicts

C Tutorials: DataTypes in C Language


C is a powerful programming language used to develop operating systems, databases, and more. It is an excellent language to learn for beginners. To work with the C programming language, you will need to have a good understanding of C data types. Whenever we define a variable in a C program, we need to specify the type of data. This helps the compiler know what type of data to expect and which operations can be performed. In this blog, we will learn what data types are in c programming and look at different data types in the C programming language.


Data types are the type of data stored in a C program. Data types are used while defining a variable or functions in C. It’s important for the compiler to understand the type of predefined data it will encounter in the program. In general terms, a data type is an attribute that tells a computer how to interpret the value.


C provides several built-in data types, such as integer (int), character (char), floating-point (float), and double-precision floating-point (double), among others. Each data type has its own set of possible values and operations that can be performed on it.

In the c programming language, data types are classified as follows...

1. Primary data types (Basic data types OR Predefined data types)

2. Derived data types (Secondary data types OR User-defined data types)

3. Enumeration data types

4. Void data type


Primary data types

The primary data types in the C programming language are the basic data types. All the primary data types are already defined in the system. Primary data types are also called as Built-In data types. The following are the primary data types in c programming language...

  1. Integer data type

  2. Floating Point data type

  3. Double data type

  4. Character data type


Integer Data type

The integer data type is a set of whole numbers. Every integer value does not have the decimal value. We use the keyword "int" to represent integer data type in c. We use the keyword int to declare the variables and to specify the return type of a function. The integer data type is used with different type modifiers like short, long, signed and unsigned. The following table provides complete details about the integer data type.

Floating Point data types

Floating-point data types are a set of numbers with the decimal value. Every floating-point value must contain the decimal value. The floating-point data type has two variants...

  • float

  • double

We use the keyword "float" to represent floating-point data type and "double" to represent double data type in c. Both float and double are similar but they differ in the number of decimal places. The float value contains 6 decimal places whereas double value contains 15 or 19 decimal places. The following table provides complete details about floating-point data types.


Character data type

The character data type is a set of characters enclosed in single quotations. The following table provides complete details about the character data type.

void data type

The void data type means nothing or no value. Generally, the void is used to specify a function which does not return any value. We also use the void data type to specify empty parameters of a function.


Enumerated data type

An enumerated data type is a user-defined data type that consists of integer constants and each integer constant is given a name. The keyword "enum" is used to define the enumerated data type.


Derived data types

Derived data types are user-defined data types. The derived data types are also called as user-defined data types or secondary data types. In the c programming language, the derived data types are created using the following concepts...

  • Arrays

  • Structures

  • Unions

  • Enumeration

Now we have almost discussed all of the data types you will need during your programming journey with C. It might have appeared overwhelming to you to learn about so many data types. But it is very important to know about these data types. And as you start using them, you will become more comfortable. Also you can learn C language tutorial in-depth for clearing your basics and that can help you gain the job-ready skills you need to get started in the exciting field of programming.


Conclusion In this article, we learnt:

  • The different categories on which we can differentiate data types, i.e. primary and secondary.

  • We understood different primary data types including integer, character, float, void.

  • We also learnt how to use secondary data types like user-defined data types and derived data types.

3 views0 comments

Commentaires


bottom of page