Skip to main content

1. Introduction to User-Defined Data Types

1.1 Why User-Defined Types?

In previous modules, we learned about basic data types like int, float, char, etc. These are sufficient for simple programs, but real-world applications often require more complex data structures.

Example Problem: Suppose you want to store information about a student:

// Without user-defined types - difficult to manage
int student_id = 12345;
char student_name[50] = "Alice Johnson";
float student_gpa = 3.75;
int student_age = 20;
char student_major[30] = "Electrical Engineering";

// If you have 100 students, you need 500 variables!

User-defined types solve this problem by allowing us to group related data together.