Pointers in C | Chapter 8 |  Class 10 Computer Science 571(NCERT) Question and Answer | Class 10 Computer Science 571(NCERT) Question and Answer Solutions English Medium |


Pointers in C

Chapter 8



Exercise


1. How is a pointer variable different from a normal variable?

(এটা পইণ্টাৰ ভেৰিয়েবল এটা সাধাৰণ ভেৰিয়েবলৰ পৰা কেনেকৈ পৃথক?)

 Ans: pointer variables (or pointers for short) are essentially the same as other variables, which can store a piece of data. Unlike common variables that store a value (e.g., int, double, mister), the cursor stores a memory address. Cursors must be declared before they are used as normal variables.

(পইণ্টাৰ ভেৰিয়েবল (বা চমুকৈ পইণ্টাৰ) মূলতঃ আন চলকৰ দৰে একে, যি ডাটাৰ টুকুৰা এটা সংৰক্ষণ কৰিব পাৰে। মূল্য এটা সংৰক্ষণ কৰা সাধাৰণ চলকৰ বিপৰীতে (যেনে, ইণ্ট, ডাবল, মিষ্টাৰ), কাৰ্চাৰে মেম'ৰী ঠিকনা এটা সংৰক্ষণ কৰে। কাৰ্চাৰবোৰ সাধাৰণ চলক হিচাপে ব্যৱহাৰ কৰাৰ আগতে ঘোষণা কৰিব লাগিব।)

2. Why is dynamic memory allocation an efficient memory management technique?

(ডাইনামিক মেমৰি আবণ্টন কিয় এটা দক্ষ মেমৰি ব্যৱস্থাপনা কৌশল?)

Ans: Dynamic memory allocation is a computer programming technique used to manage memory more efficiently. It allows a program to allocate memory blocks, make them free, and reassign them during program editing

(ডাইনামিক মেমৰি আৱণ্টন হৈছে মেমৰি অধিক দক্ষতাৰে পৰিচালনা কৰিবলৈ ব্যৱহাৰ কৰা এক কম্পিউটাৰ প্ৰগ্ৰামিং কৌশল। ই প্ৰ'গ্ৰাম এটাক মেম'ৰী ব্লক আৱণ্টন কৰিবলৈ, সেইবোৰ বিনামূলীয়া কৰিবলৈ আৰু প্ৰ'গ্ৰাম সম্পাদনাৰ সময়ত সেইবোৰ পুনৰ আৱণ্টন কৰিবলৈ অনুমতি দিয়ে)

3. How many bytes are needed to store an int pointer variable? Is it the same for a char pointer variable? Write a simple C program to explain your answer.

(এটা ইণ্ট পইণ্টাৰ চলক সংৰক্ষণ কৰিবলৈ কিমানটা বাইটৰ প্ৰয়োজন? চাৰ পইণ্টাৰ চলকৰ বাবে এইটো একে নেকি? আপোনাৰ উত্তৰ বুজাবলৈ এটা সৰল চি প্ৰ'গ্ৰাম লিখক।)

Ans: The size of the cursor variables is the same for each data type. It will be 8 bytes for the 64-bit processor, 4 bytes for the 32-bit processor, 2 bytes for the 16-bit processor.

(প্ৰতিটো ডাটা প্ৰকাৰৰ বাবে কাৰ্চৰ চলকৰ আকাৰ একে। ই 64-বিট প্ৰচেছৰৰ বাবে 8 বাইট, 32-বিট প্ৰচেছৰৰ বাবে 4 বাইট, 16-বিট প্ৰচেছৰৰ বাবে 2 বাইট হ'ব।)

4. Write the output of the following code segment.

(নিম্নলিখিত কোড খণ্ডৰ আউটপুট লিখক।)

a.










Ans: Output was 9 


b.











Ans: Output was 9 and 10

C.











Ans: Output was 10


d. 








Ans: Output was 10


e. 







Ans: Output was A


f. 







Ans: Output was B

g. 








Ans: Output was B

5. Write a C program to dynamically allocate memory for an array to store 10 integers and display the first 5 out of them.

( 10 টা ইণ্টেগাৰ সংৰক্ষণ কৰিবলৈ আৰু সেইবোৰৰ ভিতৰত প্ৰথম 5 টা প্ৰদৰ্শন কৰিবলৈ এৰেএটাৰ বাবে গতিশীলভাৱে মেম'ৰী আৱণ্টন কৰিবলৈ এটা চি প্ৰ'গ্ৰাম লিখক।)

Ans: 


6. Write a C program to dynamically allocate memory for an array to store runs scored by Virat Kohli in the last ten ODI cricket matches. Write a function to find the maximum one.

(যোৱা দহখন এদিনীয়া ক্ৰিকেট খেলত বিৰাট কোহলীয়ে সংগ্ৰহ কৰা ৰাণ সংৰক্ষণ কৰিবলৈ গতিশীলভাৱে মেমৰি আৱণ্টন কৰিবলৈ এটা চি প্ৰগ্ৰাম লিখক। সৰ্বাধিক এটা বিচাৰিবলৈ ফাংচন এটা লিখক।)
Ans: 

7. Write a C program and define a function that takes the length of your name as an input parameter and then allocates memory dynamically to store your name. Write another function to display the name.

এটা চি প্ৰ'গ্ৰাম লিখক আৰু এটা ফাংচন নিৰ্ধাৰণ কৰক যি আপোনাৰ নামৰ দৈৰ্ঘ্যক ইনপুট প্ৰাচল হিচাপে লয় আৰু তাৰ পিছত আপোনাৰ নাম সংৰক্ষণ কৰিবলৈ গতিশীলভাৱে মেমৰি আৱণ্টন কৰে। নামটো প্ৰদৰ্শন কৰিবলৈ আন এটা ফাংচন লিখক।

8. Write a C program to store some integer variables in an array. Then write functions to the following.

এটাত কিছুমান ইণ্টিগাৰ চলক সংৰক্ষণ কৰিবলৈ এটা চি প্ৰ'গ্ৰাম লিখক। তাৰ পিছত নিম্নলিখিতবোৰলৈ ফাংচনবোৰ লিখক।

1. To calculate the number of even numbers in the array.

(এৰেত সমান সংখ্যাৰ সংখ্যা গণনা কৰিবলৈ।)

Ans: 

2. To dynamically allocate memory to a new array to store only the even numbers.

 কেৱল সমান সংখ্যাবোৰ সংৰক্ষণ কৰিবলৈ নতুন এৰেএটাত গতিশীলভাৱে মেম'ৰী আৱণ্টন কৰিবলৈ।


3. To copy the even numbers from the first array to the second one.

প্ৰথম এৰেৰ পৰা দ্বিতীয়টোলৈ সমান নম্বৰবোৰ প্ৰতিলিপি কৰিবলৈ।

Sample run:


First array


Second array




9. Write a C program to store some integer variables in an array. Then write functions to the following.

এৰেএটাত কিছুমান ইণ্টিগাৰ চলক সংৰক্ষণ কৰিবলৈ এটা চি প্ৰ'গ্ৰাম লিখক। তাৰ পিছত নিম্নলিখিতবোৰলৈ ফাংচনবোৰ লিখক।

1. To calculate the number of non-zero elements that are divisible by 3.

3-ৰ দ্বাৰা বিভাজ্য নোহোৱা অ-শূন্য উপাদানৰ সংখ্যা গণনা কৰিবলৈ।

2. To dynamically allocate memory to a new array to store only those elements.

 কেৱল সেই উপাদানবোৰ সংৰক্ষণ কৰিবলৈ নতুন এৰেএটাত গতিশীলভাৱে মেমৰি আৱণ্টন কৰিবলৈ।

3. To copy the selected elements from the first array to the second one.

বাছনি কৰা উপাদানবোৰ প্ৰথম এৰেৰ পৰা দ্বিতীয়টোলৈ প্ৰতিলিপি কৰিবলৈ।

4. To calculate the summation of these elements.

 এই উপাদানবোৰৰ সাৰাংশ গণনা কৰিবলৈ।

Sample run:


First array


Second array



Summation: 24


Type & Assamese Translate : Himashree Bora.