Lecture 7 Flashcards
Structure
What is the primary purpose of arrays in programming?
Arrays allow the combination of multiple elements of the same type under one logical entity
How do structures differ from arrays in programming?
Structures allow you to combine elements of different types under one logical entity
What is the purpose of defining a new type called struct student?
It creates a new data type that allows you to group multiple related variables (members) of potentially different types under one logical entity.
Does defining struct student allocate memory for an instance?
No, defining a struct does not declare a new instance or allocate any memory; it only defines the type.
Where in a program should the definition of a struct type be placed?
The definition of a struct should be placed at the top of the program, outside any functions, and is almost always in header files.
How do you create an instance of the struct student type?
You can create an instance by declaring it as struct student s; or struct student s1, s2;.
How do you access individual members of a struct variable?
You access members using the dot operator, e.g., s.number, s.grade, etc
What is the role of the dot operator in relation to structures?
The dot operator (.) is used to access individual members of a previously declared structure variable.
What does defining a structure do in C?
Defining a structure tells the compiler about the new type but does not allocate any storage for it.
What is the purpose of declaring a variable of a particular structure type?
Declaring a variable specifies the type and gives an identifier (name) to that variable, which allows storage allocation.
What is the primary distinction between defining a structure and declaring a variable of that structure type?
Defining a structure introduces the type to the compiler, while declaring a variable allocates memory and associates it with a name.
A binary digit is called?
a “bit”
What is the significance of the index of each byte in memory?
The index of each byte is known as its address, which uniquely identifies that byte in memory.
What is Binary?
a number system comprised of 2 digits; 0 and 1
How can you conceptualize the memory of a computer system?
The memory of a computer system can be thought of as an array of bytes connected to the processor.