C programming language provides several built-in data types that can be used to define variables and functions. These data types can be broadly categorized into the following categories:
1. Basic Data Types: These are the fundamental data types in C and include:
– int: used to represent integers
– char: used to represent a single character
– float: used to represent single-precision floating-point numbers
– double: used to represent double-precision floating-point numbers
2. Derived Data Types: These data types are derived from the basic data types and include:
– array: used to represent a collection of elements of the same data type
– pointer: used to store the memory address of another variable
– structure: used to represent a collection of variables of different data types
– union: used to represent a collection of variables that share the same memory location
3. Enumerated Data Type: This data type is used to define a set of named constants that represent a group of related values.
4. Void Data Type: This data type is used to represent the absence of a value.
Here’s an example of how to define variables using these data types:
int age = 25; char grade = 'A'; float pi = 3.14; double salary = 50000.00; int numbers[5] = {1, 2, 3, 4, 5}; int *ptr; struct student { char name[50]; int age; }; enum color {RED, GREEN, BLUE}; void *ptr_void;
In this example, we have defined variables for each of the basic data types, as well as an array, a pointer, and a structure. We have also defined an enumerated data type and a void pointer.