C

1. Basic Data Types (Primary)

These are the most commonly used types for storing simple values.

Data TypeDescriptionSize (Typical)Range (Approx.)
intIntegers (whole numbers)4 bytes$-2,147,483,648$ to $2,147,483,647$
charSingle characters/alphabets1 byte$-128$ to $127$ (ASCII values)
floatSingle-precision decimals4 bytesUp to 6-7 decimal places
doubleDouble-precision decimals8 bytesUp to 15 decimal places

2. Derived Data Types

These types are "derived" from the basic data types and allow for more complex data structures:

  • Arrays: A collection of elements of the same type (e.g., int marks[5];).

  • Pointers: Variables that store the memory address of another variable.

  • Functions: Blocks of code that return a specific data type.

3. User-Defined Data Types

C allows you to create your own types to better represent real-world data:

  • struct (Structure): Groups different data types under one name.

  • union: Similar to structures but shares the same memory location for all members.

  • enum (Enumeration): Assigns names to integral constants to make code more readable.

4. The void Type

The void type signifies "no value." It is primarily used:

  • As a return type for functions that do not return a value.

  • To create "generic" pointers that can point to any data type.

Type Modifiers

You can further adjust the size or range of basic types using modifiers:

  • short / long: Changes the memory size (e.g., long int).

  • signed / unsigned: Determines if the variable can hold negative numbers (e.g., unsigned int only holds positive values).

Important Note: The exact size of data types can vary depending on your compiler and system architecture (e.g., 32-bit vs. 64-bit). You can always check the size on your specific machine using the sizeof() operator.

Upcoming Course
Upcoming Course
Learn More
Instructor Tips
Instructor Tips
View Tips
Join Community
Join Community
Join Now