W5 - STRUCTURES Flashcards

1
Q

W5-1: What is STRUCTURE?

A

_ The most commonly used data structure in (C) programs aside from the array is the STRUCT or STRUCTURE

_ A STRUCTURE type is a collection of NOT necessarily IDENTICAL types

_ use the STRUCTURE type to define a GROUP of variables as a SINGLE object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

W5-2: What is a TYPE?

A

_ A TYPE describes how to interpret the INFO stored in a region of MEMORY

_ In (C), a type may be a PRIMITIVE type or a DERIVED type

_ A DERIVED type is a collection of other types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

W5-3: PRIMITIVE TYPES include:

A

1/ char 2/ int
3/ float 4/double

Each type defines how a VALUE of that type is stored in a region of MEMORY.

Consider the int type. A value of int type is stored in equivalent BINARY representation in 4 bytes on a 32-bit platform

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

W5-4: DERIVED TYPES

A
The declaration of a derived type in (C) takes the form:
 struct Tag {
    //... declarations here
 };

struct identifies a derived type or structure
Tag is the name by which we call the structure
The declaration concludes with a semi-colon.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

W5-5: INITIALIZATION

A

_ To initialize an object of a structure, add a braces-enclosed, comma-separated list of values.

_ organize the INITIAL values in the SAME ORDER as the member listing in the declaration of the structure.

_ The initialization takes the form
struct Tag identifier = { value, … , value };

How well did you know this?
1
Not at all
2
3
4
5
Perfectly