Junior — Middle
Can you list the main data types used in programming?
sobes.tech AI
Answer from AI
The main data types in programming can be divided into several categories:
-
Primitive types:
- Integer types (int, long, short, etc.) — for storing whole numbers
- Floating-point types (float, double) — for numbers with decimal points
- Characters (char) — for storing a single character
- Boolean (bool) — for storing true/false values
-
Composite types:
- Strings (string) — sequence of characters
- Arrays — ordered collections of elements of the same type
- Tuples — immutable sequences
-
Reference types (in C#):
- Classes — objects with methods and fields
- Interfaces
- Delegates
- Arrays
-
Special types:
- Nullable types — allow storing a value or null
- Enum — enumerations
Example in C#:
int number = 10;
double price = 99.99;
char letter = 'A';
bool isActive = true;
string name = "John";
int[] numbers = {1, 2, 3};
class Person {
public string FirstName;
public string LastName;
}
Thus, the main data types are numbers, characters, boolean values, strings, arrays, and objects.