Chapter 9 -
STRUCTURE IN C
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.
(স্ট্রাকচার (যাদের স্ট্রাকচারও বলা হয়) হল একাধিক সম্পর্কিত ভেরিয়েবলকে একটি স্থানে গোষ্ঠীবদ্ধ করার একটি উপায়। স্ট্রাকচারের প্রতিটি ভেরিয়েবলকে স্ট্রাকচারের সদস্য হিসাবে পরিচিত। একটি অ্যারের বিপরীতে, একটি স্ট্রাকচারে বিভিন্ন ধরণের ডেটা থাকতে পারে যেমন int, float, mister ইত্যাদি।)
তিনটি স্বতন্ত্র ধরণের অ্যারে রয়েছে: ইনডেক্সড অ্যারে, মাল্টিডাইমেনশনাল অ্যারে এবং কোলাবোরেটরি অ্যারে।)
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.
(স্ট্রাকচার লার্নারের জন্য একটি পয়েন্টার ঘোষণা করুন (প্রশ্ন নং ৫ থেকে) এবং গতিশীলভাবে ১০টি রেকর্ডের জন্য মেমরি বরাদ্দ করুন।)
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 এর জন্য গতিশীল মেমরি বরাদ্দ সহজতর করার জন্য প্রশ্ন নং ৭-এ প্রোগ্রামটি পুনর্লিখন করুন। ব্যবহারকারীর ইনপুটে N থাকা রেকর্ডের সংখ্যা।