Crazy Code on Nostr: 1- Data Type : Primitive Data Types A-int: *Data type for an integer. *Used to store ...
1- Data Type :
Primitive Data Types
A-int:
*Data type for an integer.
*Used to store whole numbers without fractions.
*Typical size: 4 bytes.
*Example: int age = 25;
B-char:
*Data type for a single character.
*Used to store a single character (like 'a' or '1').
*Typical size: 1 byte.
*Example: char grade = 'A';
C-float:
*Data type for a single-precision floating point number.
*Used to store decimal numbers.
*Typical size: 4 bytes.
*Example: float temperature = 36.6;
D-double:
*Data type for a double-precision floating point number.
*Used to store decimal numbers with greater precision than float.
*Typical size: 8 bytes.
*Example: double distance = 12345.6789;
E-bool:
*Data type for a boolean value.
*Used to store true or false values.
*Typical size: 1 byte (sometimes implemented as 1 bit).
*Example: bool isAlive = true;
----------------------------------------------------------------------------------------
Derived Data Types :
X- Array:
*A collection of elements of the same type stored in contiguous memory locations.
*Example: int numbers[5] = {1, 2, 3, 4, 5};
Y- Pointer:
*A variable that stores the memory address of another variable.
*Example: int* ptr = &age;
Z- Reference:
*An alias for another variable.
*Example: int& ref = age;