Data Types in C
In C programming, data types define the type of data a variable can hold. They are broadly categorized into basic, derived, and user-defined types. Here's a concise overview:
1. Basic Data Types
These are the fundamental types used to define variables.
Type Description Size (in bytes) Example
int Integer values Typically 4 int age = 25;
float Single-precision float Typically 4 float pi = 3.14;
double Double-precision float Typically 8 double e = 2.718;
char Single character Typically 1 char grade = 'A';
2. Derived Data Types
These are built from basic types.
Array: Collection of elements of the same type.
Example: int arr[5] = {1, 2, 3, 4, 5};
Pointer: Stores the address of another variable.
Example: int *ptr = &age;
Structure: Groups variables of different types.
Example:
Copy the code
struct Student {
int id;
char name[50];
};
Union: Similar to structures but shares memory.
Example:
Copy the code
union Data {
int i;
float f;
};
3. User-Defined Data Types
These allow customization of data types.
typedef: Creates an alias for a data type.
Example: typedef unsigned int uint;
enum: Defines a set of named integer constants.
Example:
Видео Data Types in C канала Jasmine Antony Raj A SNS
1. Basic Data Types
These are the fundamental types used to define variables.
Type Description Size (in bytes) Example
int Integer values Typically 4 int age = 25;
float Single-precision float Typically 4 float pi = 3.14;
double Double-precision float Typically 8 double e = 2.718;
char Single character Typically 1 char grade = 'A';
2. Derived Data Types
These are built from basic types.
Array: Collection of elements of the same type.
Example: int arr[5] = {1, 2, 3, 4, 5};
Pointer: Stores the address of another variable.
Example: int *ptr = &age;
Structure: Groups variables of different types.
Example:
Copy the code
struct Student {
int id;
char name[50];
};
Union: Similar to structures but shares memory.
Example:
Copy the code
union Data {
int i;
float f;
};
3. User-Defined Data Types
These allow customization of data types.
typedef: Creates an alias for a data type.
Example: typedef unsigned int uint;
enum: Defines a set of named integer constants.
Example:
Видео Data Types in C канала Jasmine Antony Raj A SNS
Комментарии отсутствуют
Информация о видео
20 июля 2025 г. 8:02:12
00:05:12
Другие видео канала