

Structures in C
Presentation
•
Computers
•
12th Grade
•
Easy
Used 14+ times
FREE Resource
13 Slides • 9 Questions
1
Structures in C

2
Lesson Objectives:
Define the term 'structure' as it relates to programming.
Differentiate between a structure and an array.
Implement structures in C programming.
3
What is a structure?
A structure is a user defined data type in C/C++. A structure creates a data type that can be used to group items of possibly different types into a single type.
4
How does a structure differ from an array?
Arrays allow to define type of variables that can hold several data items of the same kind. Similarly structure is another user defined data type available in C that allows to combine data items of different kinds.
5
Multiple Choice
A structures are similar to array in that they can store multiple data items.
True
False
6
Multiple Choice
A structures are similar to array in that they can store multiple data items.
True
False
7
Understanding structures
Structures are used to represent a record. Suppose you want to keep track of your books in a library. You might want to track the following attributes about each book −
* Title
* Author
* Subject
* Book ID
8
Defining a structure
To define a structure, you must use the struct statement. The struct statement defines a new data type, with more than one member. The format of the struct statement is as follows −
struct [structure tag] {
------member definition;
------ member definition;
------ ...
------member definition;
} [one or more structure variables];
9
Example of Structure Definition
The structure tag is optional and each member definition is a normal variable definition, such as int i; or float f; or any other valid variable definition. At the end of the structure's definition, before the final semicolon, you can specify one or more structure variables but it is optional. Here is the way you would declare the Book structure −
10
Multiple Choice
How many members does struct Books contain?
1
0
3
4
11
Multiple Choice
How many data types are in struct Books?
1
2
3
4
12
Accessing Structure Members
To access any member of a structure, we use the member access operator (.). The member access operator is coded as a period between the structure variable name and the structure member that we wish to access. You would use the keyword struct to define variables of structure type. The following example shows how to use a structure in a program −
13
14
Using typedef with struct
typedef is a keyword used in C language to assign alternative names to existing datatypes. Its mostly used with user defined datatypes, when names of the datatypes become slightly complicated to use in programs.
15
Using typedef with struct
typedef is a keyword used in C language to assign alternative names to existing datatypes. Its mostly used with user defined datatypes, when names of the datatypes become slightly complicated to use in programs.
16
17
Open Ended
Which structure variable name are the members of struct Books being accessed using?
18
Open Ended
Respond to the following:
A car dealership desires to store the following information on vehicles:
*year
*brand
*model
*price
Define a struct 'Cars' to store the data.
19
Open Ended
Write a line of code giving struct Cars an alternate name.
20
Open Ended
Write a line of code to store the value 2020 in the year variable using the alternative struct name you declared.
21
Time to Code!!!
Open your C compiler and let's have some FUN :)
22
Open Ended
Your response here
Structures in C

Show answer
Auto Play
Slide 1 / 22
SLIDE
Similar Resources on Wayground
17 questions
Least Squares Regression Line Practice
Presentation
•
12th Grade
17 questions
Credit Score
Presentation
•
12th Grade
18 questions
SHOULD, HAVE TO, MUST
Presentation
•
12th Grade
15 questions
Judicial Branch
Presentation
•
12th Grade
15 questions
4.3 Two-Way Tables Probability
Presentation
•
12th Grade
18 questions
Freshwater Ecology Notes
Presentation
•
12th Grade
14 questions
PROCEDURE TEXT : MANUAL
Presentation
•
12th Grade
18 questions
Python- Function (Parameter, Argument and Return)
Presentation
•
12th Grade
Popular Resources on Wayground
16 questions
Grade 3 Simulation Assessment 2
Quiz
•
3rd Grade
19 questions
HCS Grade 5 Simulation Assessment_1 2526sy
Quiz
•
5th Grade
10 questions
Cinco de Mayo Trivia Questions
Interactive video
•
3rd - 5th Grade
17 questions
HCS Grade 4 Simulation Assessment_2 2526sy
Quiz
•
4th Grade
24 questions
HCS Grade 5 Simulation Assessment_2 2526sy
Quiz
•
5th Grade
13 questions
Cinco de mayo
Interactive video
•
6th - 8th Grade
20 questions
Math Review
Quiz
•
3rd Grade
30 questions
GVMS House Trivia 2026
Quiz
•
6th - 8th Grade