Structures

Raheelanjum
2 min readDec 6, 2024

Structures represent a "named" collection of related data. For anything in a computer more complicated than a list of numbers, structures can be used. For example, to represent any given car, we might want to know how many doors it has, if it has AC, what its max speed is, etc. All of this information relates to a single "Car" entity and should be saved in a computer using a structured data type. We use the "DOT" notation to access a structure stored in a variable; thus, car.max_speed, car.number_of_doors, and car.ac are all valid references to a structure.

Structure

A structure is one of the 5 data types in programming. A structure is used to represent information about something more complicated than a single number, character, or boolean can do (and more complicated than an array of the above data types can do). For example, a student can be defined by his or her name, GPA, age, UID, etc. Each of these pieces of information should be labeled with an easily understood descriptive title and then combined to form a whole (the structure).

Jim';

student.gpa = 4.0;a = 4.0;

Above we create a variable called student. The student variable is of TYPE: STRUCTURE. The structure has two fields. The names of the fields are "name" and "gpa." The name field tells the programmer that this data represents the name of the student…

--

--

Raheelanjum
Raheelanjum

Written by Raheelanjum

Highly skilled and experienced content writer dedicated to crafting compelling, informative content that resonates with diverse audiences. Expertise spans blog

Responses (12)