Unit 4
Unit 4
_______________________________________________________________________________________________
Date:_______________________________
Practical 24 to 26
Questions(Handwritten):
1. Why are structures and unions important in programming? Provide examples, such as
using a structure to store student data (name, roll number, marks) or a union to efficiently
manage memory for a variable that stores multiple data types at different times.
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
-------------------
2. What are the key differences between structures and unions in terms of memory
usage and access to members? Provide a scenario where a structure is preferred (e.g.,
storing employee details) and where a union is more suitable (e.g., managing a variable
that alternates between data types).
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
CEUC101-Computer Concepts & Programming Programming Roll Number:________
_______________________________________________________________________________________________
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
-----------------------------
3. How are structure and union variables declared and accessed? Explain with an example,
such as declaring a structure variable for storing a book's details (title, author, price) or a
union variable for managing sensor data (integer ID or float value).
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------