Structure in C | Chapter 9 | Class 10 Computer Science 571(NCERT) Question and Answer | Class 10 Computer Science 571(NCERT) Question and Answer Solutions English Medium |
Structure in C
Chapter 9
1. Define structure in the context of a programming language. How is it different from an array?
(āĻĒ্ā§°āĻ্ā§°েāĻŽিং āĻাāώাā§° āĻĒ্ā§°āϏংāĻāϤ āĻāĻ āύ āϏংāĻ্āĻাāϝ়িāϤ āĻā§°া। āĻā§°েā§° āĻĒā§°া āĻ āĻেāύেāĻৈ āĻĒৃāĻĨāĻ?)
Ans: Structures (also called structures) are a way of grouping multiple related variables into one space. Each variable in the structure is known as a member of the structure. Unlike an array, a structure can have different data types Int, Float, Mister, etc.
There are three different kinds of arrays: indexed arrays, multidimensional arrays, and associative arrays.
( āĻাঁāĻĨāύিāĻŦোā§° (āϝাāĻ āĻাঁāĻĨāύি āĻŦুāϞিāĻ āĻোā§ąা āĻšāϝ়) āĻšৈāĻে āĻāĻাāϧিāĻ āϏāĻŽ্āĻĒā§°্āĻিāϤ āĻāϞāĻāĻ āĻāĻা āϏ্āĻĨাāύāϤ āĻোāĻ āĻā§°াā§° āĻāĻ āĻāĻĒাāϝ়। āĻাঁāĻĨāύিāĻোā§° āĻĒ্ā§°āϤিāĻো āĻāϞāĻāĻ āĻাঁāĻĨāύিāĻোā§° āϏāĻĻāϏ্āϝ āĻšিāĻাāĻĒে āĻāύা āϝাāϝ়। āĻā§°েāĻāĻাā§° āĻŦিāĻĒā§°ীāϤে, āĻাঁāĻĨāύি āĻāĻাāϤ āĻŦিāĻিāύ্āύ āĻĄাāĻা āĻĒ্ā§°āĻাā§°ā§° āĻāĻŖ্āĻ, āĻĢ্āϞোāĻ, āĻŽিāώ্āĻাā§° āĻāĻĻি āĻĨাāĻিāĻŦ āĻĒাā§°ে।
āĻāϝ়াāϤ āϤিāύিāĻা āĻĒৃāĻĨāĻ āĻĒ্ā§°āĻাā§°ā§° āĻā§°ে āĻāĻে: āϏূāĻীāĻŦāĻĻ্āϧ āĻā§°ে, āĻŦāĻšুāĻŽাāϤ্ā§°িāĻ āĻā§°ে, āĻā§°ু āϏāĻšāϝোāĻী āĻā§°ে।)
2. Is structure a built-in data type? Can we apply basic arithmetic operations such as addition, subtraction to structure variables? Show with a simple C program.
(āĻāĻ āύ āĻāĻা āĻŦিāϞ্āĻ-āĻāύ āĻĄাāĻা āĻাāĻāĻĒ āύেāĻি? āĻāĻŽি āĻāĻ āύ āĻāϞāĻāϏāĻŽূāĻšāϤ āϝোāĻ, āĻŦিāϝ়োāĻ āĻāĻĻি āĻŽৌāϞিāĻ āĻাāĻŖিāϤিāĻ āĻাā§°্āϝ্āϝāϏāĻŽূāĻš āĻĒ্ā§°āϝ়োāĻ āĻā§°িāĻŦ āĻĒাā§°োāύে? āĻāĻা āϏাāϧাā§°āĻŖ C āĻĒ্ā§°āĻ্ā§°েāĻŽā§° āϏৈāϤে āĻĻেāĻুā§ąাāĻāĻ।)
Ans: Structure is a built-in - not a data type. We can group different types of constructed information into a structure. Yes, we can apply deductions to basic mathematical tasks such as mixing, structure variables, etc.
(āĻাঁāĻĨāύি āĻāĻা āĻŦিāϞ্āĻ-āĻāύ - āĻĄাāĻা āĻĒ্ā§°āĻাā§° āύāĻšāϝ়। āĻāĻŽি āĻŦিāĻিāύ্āύ āĻĒ্ā§°āĻাā§°ā§° āύিā§°্āĻŽিāϤ āϤāĻĨ্āϝāĻāĻা āĻাঁāĻĨāύিāϤ āĻোāĻ āĻā§°িāĻŦ āĻĒাā§°োঁ। āĻšāϝ়, āĻāĻŽি āĻĒ্ā§°াāĻĨāĻŽিāĻ āĻাāĻŖিāϤিāĻ āĻাā§°্āϝāϝেāύে āĻŽিāĻļ্ā§°āĻŖ, āĻাঁāĻĨāύি āĻāϞāĻāĻāĻĻিāϤ āĻā§°্āϤāύ āĻĒ্ā§°āϝ়োāĻ āĻā§°িāĻŦ āĻĒাā§°োঁ।)
3. Identify the members of the structure from the below code segment.
(āϤāϞ⧰ āĻ'āĻĄ āĻāĻŖ্āĻĄā§° āĻĒā§°া āĻāĻ āύ⧰ āϏāĻĻāϏ্āϝāϏāĻŽূāĻš āĻিāύাāĻ্āϤ āĻā§°āĻ।)
4. Identify the structure variables from the below code segment.
(āϤāϞ⧰ āĻ'āĻĄ āĻāĻŖ্āĻĄā§° āĻĒā§°া āĻāĻ āύ āĻāϞāĻāϏāĻŽূāĻš āĻিāύাāĻ্āϤ āĻā§°āĻ।)
5. Consider the structure below and write statements for the following.
(āϤāϞ⧰ āĻāĻ āύāĻো āĻŦিāĻŦেāĻāύা āĻā§°āĻ āĻā§°ু āϤāϞ⧰āĻŦোā§°ā§° āĻŦাāĻŦে āĻŦিāĻŦৃāϤি āϞিāĻāĻ।)
a. to declare a variable of the structure
(āĻāĻ āύ⧰ āĻāĻা āĻāϞāĻ āĻোāώāĻŖা āĻā§°িāĻŦāϞৈ)
Ans: The "structure declaration" provides a type of name and determines different types of variable values (called "members" or "fields"). An alternative identifier called "tag" mentions the type of structure and can be used in the next context of the type 0 of the structure
( "āĻাঁāĻĨāύি āĻোāώāĻŖা"-āĻ āĻāĻ āĻĒ্ā§°āĻাā§°ā§° āύাāĻŽ āĻĒ্ā§°āĻĻাāύ āĻā§°ে āĻā§°ু āĻŦিāĻিāύ্āύ āĻĒ্ā§°āĻাā§°ā§° āĻĒā§°িā§ąā§°্āϤāύāĻļীāϞ āĻŽাāύ (āϝাāĻ "āϏāĻĻāϏ্āϝ" āĻŦা "āĻ্āώেāϤ্ā§°" āĻŦুāϞি āĻোā§ąা āĻšāϝ়) āύিā§°্āϧাā§°āĻŖ āĻā§°ে। "āĻেāĻ" āĻŦুāϞি āĻোā§ąা āĻāĻ āĻŦৈāĻāϞ্āĻĒিāĻ āĻিāύাāĻ্āϤāĻā§°্āϤাāĻ āĻাঁāĻĨāύিā§° āĻĒ্ā§°āĻাā§° āĻāϞ্āϞেāĻ āĻā§°ে āĻā§°ু āĻাঁāĻĨāύিā§° āĻĒ্ā§°āĻাā§°-ā§° āĻĒā§°ā§ąā§°্āϤী āĻĒ্ā§°āϏংāĻāϤ āĻŦ্āĻ¯ā§ąāĻšাā§° āĻā§°িāĻŦ āĻĒাā§°ি)
b. to display the age of the teacher
(āĻļিāĻ্āώāĻā§° āĻŦāϝ়āϏ āĻĒ্ā§°āĻĻā§°্āĻļāύ āĻā§°িāĻŦāϞৈ)
Ans:
6. Declare a pointer for structure Teacher (from Q No. 5) and dynamically allocate memory for 10 records.
(āĻāĻ āύ āĻļিāĻ্āώāĻā§° āĻŦাāĻŦে āĻāĻা āĻĒāĻāĻŖ্āĻাā§° āĻোāώāĻŖা āĻā§°āĻ (āĻĒ্ā§°āĻļ্āύ āύং 5 ā§° āĻĒā§°া) āĻā§°ু 10 āĻা ā§°েāĻā§°্āĻĄā§° āĻŦাāĻŦে āĻāϤিāĻļীāϞāĻাā§ąে āĻŽেāĻŽā§°ি āĻāĻŦāĻŖ্āĻāύ āĻā§°āĻ।)
Ans:
7. Consider the structure below and write statements for the following.
(āϤāϞ⧰ āĻāĻ āύāĻো āĻŦিāĻŦেāĻāύা āĻā§°āĻ āĻā§°ু āϤāϞ⧰āĻŦোā§°ā§° āĻŦাāĻŦে āĻŦিāĻŦৃāϤি āϞিāĻāĻ।)
a. to declare a pointer for the above structure and display the salary.
(āĻāĻĒā§°ā§° āĻāĻ āύ⧰ āĻŦাāĻŦে āĻāĻা āĻĒāĻāĻŖ্āĻাā§° āĻোāώāĻŖা āĻā§°িāĻŦāϞৈ āĻā§°ু āĻĻā§°āĻŽāĻšা āĻĒ্ā§°āĻĻā§°্āĻļāύ āĻā§°িāĻŦāϞৈ।)
Ans: To declare a structure pointer struct keyword is used followed by the structure name and pointer name with an asterisk * symbol. Members of a structure can be accessed from pointers using two ways that are. Using dot and asterisk operator on a pointer. Using arrow operator (->) on a pointer
b. to declare a single pointer for two different variables of the higher structure and display the details of the employee whose salary is more.
āĻāĻ্āĻ āĻāĻ āύ⧰ āĻĻুāĻা āĻিāύ্āύ āĻāϞāĻā§° āĻŦাāĻŦে āĻāĻা āĻĒāĻāĻŖ্āĻাā§° āĻোāώāĻŖা āĻā§°িāĻŦāϞৈ āĻā§°ু āϝিāĻāύ āĻā§°্āĻŽāĻাā§°ীā§° āĻĻā§°āĻŽāĻšা āĻŦেāĻি āϤেāĻঁā§° āĻŦিā§ąā§°āĻŖ āĻĒ্ā§°āĻĻā§°্āĻļāύ āĻā§°িāĻŦāϞৈ।
8. Rewrite the program of Q. No. 7 to facilitate dynamic memory allocation for N number of record where N in a user input.
N āϏংāĻ্āϝাā§° ā§°েāĻā§°্āĻĄā§° āĻŦাāĻŦে āĻāϤিāĻļীāϞ āĻŽেāĻŽā§°ি āĻāĻŦāĻŖ্āĻāύ āϏāĻšāĻ āĻā§°ি āϤুāϞিāĻŦāϞৈ Q. āύং 7 ā§° āĻĒ্ā§°āĻ্ā§°েāĻŽāĻো āĻĒুāύ⧰ āϞিāĻāĻ āϝ'āϤ N āĻāĻা āĻŦ্āĻ¯ā§ąāĻšাā§°āĻাā§°ী āĻāύāĻĒুāĻāϤ āĻāĻে।




