In C, Datatypes are categorized into derived data types, enumeration data types, and the void data type. following is the categorization
Basic Data Types:
1. int:
·
Description: Used to store whole numbers (positive,
negative, or zero).
·
Size: Typically 4 bytes (32 bits) of memory.
·
Example: int numberOfBooks = 25;
·
Maximum size: Approximately -2.1 billion to +2.1
billion.
2. float:
·
Description: Used to store decimal numbers with
single-precision.
·
Size: Typically 4 bytes (32 bits) of memory.
·
Example: float height = 1.75;
·
Maximum size: Typically around 6-9 decimal digits of
precision.
3. double:
·
Description: Used to store decimal numbers with
double-precision.
·
Size: Typically 8 bytes (64 bits) of memory.
·
Example: double pi = 3.14159;
·
Maximum size: Typically around 15 decimal digits of
precision.
4. char:
·
Description: Used to store individual characters.
·
Size: Typically 1 byte (8 bits) of memory.
·
Example: char grade = 'A';
·
Maximum size: -128 to 127 or 0 to 255, depending on
whether it is "signed" or "unsigned".
Derived Data Types:
1. Array:
·
Description: A collection of elements of the same data
type.
·
Example:
int numbers [4] = {1,
2, 3, 4};
2. Pointer:
·
Description: Pointer is a variable that stores the
memory address of another variable.
·
Example:
int *ptr;
int number = 10;
ptr = &number;
3. 3. Structure:
·
Description: A user-defined data type that groups
together variables of different data types under one name.
·
Example:
struct Person
{
char name[20];
int age;
};
struct Person student;
4. 4. Union:
·
Description: A user-defined data type that allows
storing different data types in the same memory location.
· Example:
union Data
{
int number;
float decimal;
};
union Data value;
Enumeration Data Type:
1. 1.) enum:
·
Description: Used to define a set of named values.
·
Size: Depends on the number of elements in the enum.
·
Example:
enum fruits {Apple, Mango,
Watermelon, Papaya, Jackfruit, Strawberries};
enum fruits King = Mango;
Void Data Type
1. 1.) void:
·
Description: Used to represent the absence of type or
absence of a value.
·
Size: Not applicable (void has no size).
·
Example:
void
printHello()
{
printf("Hello!");
}
If you are beginner in C Language
don’t just focus on the code mentioned above for now, even if you understand
what are datatypes, what are its types its completely fine in upcoming blogs we
will discuss rest of the things make sure you are reading it daily, just spend 10 minutes reading this blog and
you will thank yourself for reading it alright see you soon.
Post a Comment
If you have any questions do let me know