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


Arrays in C

Chapter 6


Exercise


1. Define array. Why do we use arrays in computer programs?

(এৰে নিৰ্ধাৰণ কৰক। আমি কম্পিউটাৰ প্ৰ'গ্ৰামত এৰে কিয় ব্যৱহাৰ কৰোঁ?)

Ans: We use arrays in computer programs because-In coding and programming, arrays are a collection of items, or data, stored in adjacent memory locations, also known as database systems. The purpose of an array is to store multiple pieces of data of the same type together.


2. Can we store both integer and float types of data in a single array? Demonstrate this by writing a simple C program.

(আমি ইণ্টেগাৰ আৰু ফ্লোট প্ৰকাৰ দুয়োধৰণৰ ডাটা এটা এৰেত সংৰক্ষণ কৰিব পাৰোঁনে? এটা সৰল চি প্ৰ'গ্ৰাম লিখি ইয়াক প্ৰদৰ্শন কৰক।)

Ans: We cannot store data in both integers and float types. 

In the above program, when array elements are taken as integers, the program prints the correct output. But if we take the input as a float value (e.g. 3.14,2.54,5.7,........) an error will occur.


3. Write the indices of the first and last element of the following array declaration. char city [7]=('S', T, 'L', 'C', 'H', 'A', 'R', };

(নিম্নলিখিত এৰে ঘোষণাৰ প্ৰথম আৰু অন্তিম উপাদানৰ সূচকবোৰ লিখক। চাৰ চিটি [7]=('এছ', টি,'এল', 'চি', 'চি', 'এইচ', 'এ', 'আৰ', };)

Ans: Indices of the first element of the array is 0. and Indices of the last element of the array is 6.

( এৰে ঘোষণাৰ প্ৰথম  উপাদানৰ সূচকবোৰ হ'ল ০। আৰু এৰে ঘোষণাৰ অন্তিম উপাদানৰ সূচকবোৰ হ'ল ৬।)

4. Write a C program and declare an integer type array with capacity 7. Take input to the array from the keyboard. Display the 8th element of the array. Hint: display num[7] if num is the name of the array. Analyze the output.

(এটা চি প্ৰ'গ্ৰাম লিখক আৰু ক্ষমতা 7-ৰ সৈতে এটা ইণ্টেগাৰ প্ৰকাৰৰ এৰে ঘোষণা কৰক। কীবোৰ্ডৰ পৰা এৰেলৈ ইনপুট লওক। এৰেৰ 8ম উপাদান প্ৰদৰ্শন কৰক। ইঙ্গিত: সংখ্যা প্ৰদৰ্শন কৰক[7] যদি সংখ্যাটো এৰেৰ নাম হয়। আউটপুট বিশ্লেষণ কৰক।)

Ans: 


5. Write a C program and declare an integer type array with 7 elements in it. Display the address of the individual elements in the array.

(এটা চি প্ৰ'গ্ৰাম লিখক আৰু ইয়াত 7 টা উপাদান থকা এটা ইণ্টেগাৰ প্ৰকাৰৰ এৰে ঘোষণা কৰক। এৰেত থকা গাইগুটীয়া উপাদানবোৰৰ ঠিকনা প্ৰদৰ্শন কৰক।)

Ans: To create an array, define the type of data (for example int) and specify the name of the array after the class brackets []. To include values here, use a less-varying list within curly braces: in my number[] = {25, 50, 75, 100};

(এৰে এটা সৃষ্টি কৰিবলৈ, ডাটাৰ প্ৰকাৰ নিৰ্ধাৰণ কৰক (উদাহৰণ স্বৰূপে ইণ্ট) আৰু শ্ৰেণী বন্ধনীৰ পিছত এৰেৰ নাম নিৰ্দিষ্ট কৰক []। ইয়াত মানঅন্তৰ্ভুক্ত কৰিবলৈ, কোঁকড়া ব্ৰেছৰ ভিতৰত এক কম-পৰিৱৰ্তনশীল তালিকা ব্যৱহাৰ কৰক: ইণ্ট মাইনম্বৰ[] = {25, 50, 75, 100};)


6. Write a C program and declare two integer type arrays, each with capacity 7. Take input only to the first array. Write a loop to copy the elements of the first array to the second one. Display the elements of the second array.

(এটা চি প্ৰ'গ্ৰাম লিখক আৰু দুটা ইণ্টিগাৰ প্ৰকাৰৰ এৰে ঘোষণা কৰক, প্ৰতিটো ক্ষমতা 7 ৰ সৈতে। ইনপুট কেৱল প্ৰথম এৰেলৈ লৈ যাওক। প্ৰথম এৰেৰ উপাদানবোৰ দ্বিতীয়টোলৈ প্ৰতিলিপি কৰিবলৈ এটা লুপ লিখক। দ্বিতীয় এৰেৰ উপাদানবোৰ প্ৰদৰ্শন কৰক।)

Ans: 


7. Write a strategy to find the summation of all the even numbers stored in an array. Write a C program for the same. If the array elements are (1, 2, 4, 3, 5, 6, 7, 7, 8), the output of the program will be 20.

এৰেএটাত সঞ্চিত সকলো সমান সংখ্যাৰ সাৰাংশ বিচাৰিবলৈ কৌশল এটা লিখক। ইয়াৰ বাবে এটা চি প্ৰ'গ্ৰাম লিখক। যদি এৰে উপাদানবোৰ (1, 2, 4, 3, 5, 6, 7, 7, 8) হয়, প্ৰ'গ্ৰামটোৰ আউটপুট হ'ব 20।

Ans:


8. Write a strategy to find the summation of all the even positioned numbers stored in an array. Write a C program for the same. If the array elements are {1, 2, 4, 3, 5, 6, 7, 7, 8), the output of the program will be 18.

এৰেএটাত সঞ্চিত সকলো সমান অৱস্থানযুক্ত সংখ্যাৰ সাৰাংশ বিচাৰিবলৈ কৌশল এটা লিখক। ইয়াৰ বাবে এটা চি প্ৰ'গ্ৰাম লিখক। যদি এৰে উপাদানবোৰ {1, 2, 4, 3, 5, 6, 7, 7, 8 হয়, প্ৰ'গ্ৰামটোৰ আউটপুট হ'ব 18।

Ans:


9. Write the logic to replace only the first occurrence of an element in an array. For example, if the array elements are {1, 2, 3, 4, 5, 1, 2, 3] and we want to replace element 3 by 0, the array content becomes {1, 2, 0, 4, 5, 1, 2, 3). Write a complete C program incorporating the logic.

এৰে এটাত কেৱল এটা উপাদানৰ প্ৰথম ঘটনাসলনি কৰিবলৈ যুক্তি লিখক। উদাহৰণ স্বৰূপে, যদি এৰে উপাদানবোৰ {1, 2, 3, 4, 5, 1, 2, 3] হয় আৰু আমি উপাদান 3 বাই 0 সলনি কৰিব বিচাৰো, এৰে সমল {1, 2, 0, 4, 5, 1, 2, 3) হয়। যুক্তি অন্তৰ্ভুক্ত কৰি এটা সম্পূৰ্ণ চি প্ৰ'গ্ৰাম লিখক।

Ans:


10. Write the logic to replace only the last occurrence of an element in an array. For example, if the array elements are (1, 2, 3, 4, 5, 1, 2, 3) and we want to replace element 3 by 0, the array content becomes (1, 2, 3, 4, 5, 1, 2, 0). Write a complete C program incorporating the logic.

এৰে এটাত কেৱল এটা উপাদানৰ অন্তিম ঘটনাটো সলনি কৰিবলৈ যুক্তিলিখক। উদাহৰণ স্বৰূপে, যদি এৰে উপাদানবোৰ (1, 2, 3, 4, 5, 1, 2, 3) হয় আৰু আমি উপাদান 3 বাই 0 সলনি কৰিব বিচাৰো, এৰে সমল (1, 2, 3, 4, 5, 1, 2, 0) হৈ পৰে। যুক্তি অন্তৰ্ভুক্ত কৰি এটা সম্পূৰ্ণ চি প্ৰ'গ্ৰাম লিখক।

Ans:


11. Write a C program to replace all the even positioned elements in an integer array by 0. For example, if the array elements are {1, 2, 3, 9, 5, 5, 7, 1, 9), it becomes (1, 0, 3, 0, 5, 0, 7, 0, 9).

 ইণ্টেগাৰ এৰেত সকলো সমান অৱস্থানযুক্ত উপাদান0 ৰ দ্বাৰা সলনি কৰিবলৈ এটা চি প্ৰ'গ্ৰাম লিখক। উদাহৰণ স্বৰূপে, যদি এৰে উপাদানবোৰ {1, 2, 3, 9, 5, 5, 7, 1, 9) হয়, ই (1, 0, 3, 0, 5, 0, 7, 0, 9) হৈ পৰে।

Ans:


12. Write a strategy to replace all the odd numbers in an integer array by 0. For example, if the array elements are (1, 2, 3, 9, 5, 5, 7, 1, 9), it becomes (0, 2, 0, 0, 0, 0, 0, 0, 0). Write a C program for the same.

 ইণ্টেগাৰ এৰেত সকলো বিজোড় সংখ্যা 0 ৰে সলনি কৰিবলৈ কৌশল এটা লিখক। উদাহৰণ স্বৰূপে, যদি এৰে উপাদানবোৰ (1, 2, 3, 9, 5, 5, 7, 1, 9) হয়, ই (0, 2, 0, 0, 0, 0, 0, 0, 0, 0) হয়। ইয়াৰ বাবে এটা চি প্ৰ'গ্ৰাম লিখক।

Ans:


13. Write a C program to store your name and your mother's name in two different strings. Display them one after another.

আপোনাৰ নাম আৰু আপোনাৰ মাতৃৰ নাম দুটা পৃথক স্ট্ৰিংত সংৰক্ষণ কৰিবলৈ এটা চি প্ৰ'গ্ৰাম লিখক। সিহঁতক এটাৰ পিছত এটা কৈ প্ৰদৰ্শন কৰক।

Ans:


14. Write a C program to declare 3 integer type arrays to store the marks of 10 students scored in 3 different subjects. Take another integer to store the average marks of the students. The average mark of a student is the average of the marks scored by the student in 3 subjects. This should be calculated and inserted by the program. Then you should display the average marks of the students. The program should also display "PASS" or "FAIL" along with the average as per the rule: PASS if average >= 45, FAIL otherwise.

3 টা পৃথক বিষয়ত নম্বৰ পোৱা 10 জন শিক্ষাৰ্থীৰ নম্বৰ সংৰক্ষণ কৰিবলৈ 3 টা ইণ্টেগাৰ প্ৰকাৰৰ এৰে ঘোষণা কৰিবলৈ এটা চি প্ৰ'গ্ৰাম লিখক। শিক্ষাৰ্থীসকলৰ গড় নম্বৰ সংৰক্ষণ কৰিবলৈ আন এটা ইণ্টেগাৰ লওঁক। এজন শিক্ষাৰ্থীৰ গড় চিহ্ন হৈছে 3 টা বিষয়ত শিক্ষাৰ্থীয়ে প্ৰাপ্ত কৰা নম্বৰৰ গড়। এইটো প্ৰ'গ্ৰামৰ দ্বাৰা গণনা আৰু অন্তৰ্ভুক্ত কৰিব লাগে। তেতিয়া আপুনি শিক্ষাৰ্থীসকলৰ গড় নম্বৰ প্ৰদৰ্শন কৰা উচিত। প্ৰ'গ্ৰামটোৱে নিয়ম অনুসৰি গড়ৰ সৈতে "পাছ" বা "ফেইল" প্ৰদৰ্শন কৰিব লাগে: যদি গড় >= 45, অন্যথা বিফল হয় তেন্তে পাছ কৰক।

Ans:


15. Write any two limitations of arrays. Can you store your name and roll number in the same aray?

এৰেৰ যিকোনো দুটা সীমাবদ্ধতা লিখক। আপুনি আপোনাৰ নাম আৰু ৰোল নম্বৰ একেটা আৰেত সংৰক্ষণ কৰিব পাৰিবনে?

Ans:



Type & Assamese Translate : Himashree Bora.



Post ID: DABP002256