6.5.1 Finding summation of a series of numbers.

6.5.1 সংখ্যাৰ এটা শৃংখলাৰ সংক্ষিপ্তবিৱৰণ বিচাৰি উলিওৱা।

Let us now revisit the problem of finding the summation of a series of numbers as stated in Section 6.1. We will use an array to store the numbers and then we will find the summation of those numbers.

এতিয়া আমি ধাৰা 6.1-ত উল্লেখ কৰা অনুসৰি সংখ্যাৰ এটা শৃংখলাৰ সংক্ষিপ্তবিৱৰণ বিচাৰি উলিওৱাৰ সমস্যাটো পুনৰ বিবেচনা কৰোঁ আহক। আমি নম্বৰবোৰ সংৰক্ষণ কৰিবলৈ এটা এৰে ব্যৱহাৰ কৰিম আৰু তাৰ পিছত আমি সেই সংখ্যাবোৰৰ সংক্ষিপ্তকৰণ বিচাৰি পাম।

We have already learned in the previous section about scanning numbers from the keyboard into an array. We use the same strategy for this purpose. Let us see this step by step with corresponding code segments.

আমি ইতিমধ্যে পূৰ্বৱৰ্তী শাখাত কীবৰ্ডৰ পৰা নম্বৰবোৰ এৰেলৈ স্কেন কৰাৰ বিষয়ে শিকিছোঁ। আমি এই উদ্দেশ্যৰ বাবে একেই ৰণনীতি ব্যৱহাৰ কৰোঁ। সংশ্লিষ্ট কোড খণ্ডবোৰৰ সৈতে আমি এই পদক্ষেপটো ধাপে ধাপে চাওঁ আহক।

Step 1: Declare an integer type array with sufficient capacity.

পদক্ষেপ 1: পৰ্যাপ্ত ক্ষমতাথকা ইণ্টেগাৰ প্ৰকাৰৰ এৰে ঘোষণা কৰক।

This array can store upto 20 integers.

এই এৰেটোৱে 20 টা লৈকে পূৰ্ণসংখ্যা সংৰক্ষণ কৰিব পাৰে।

Step 2: Taking input to the array elements.

পদক্ষেপ 2: এৰে উপাদানবোৰলৈ ইনপুট লোৱা।

This step can be performed with two tasks.

এই পদক্ষেপটো দুটা কামৰ সৈতে সম্পাদন কৰিব পাৰি।

Task 2.1: Asking users to enter the total number of elements in the series. This has to be less or equal to the capacity of the array. We store this in a variable “totalEle”.

কাৰ্য্য 2.1: ব্যৱহাৰকাৰীসকলক শৃংখলাটোৰ মুঠ উপাদানৰ সংখ্যা প্ৰবিষ্ট কৰিবলৈ কোৱা। এইটো এৰেৰ ক্ষমতাৰ কম বা সমান হ’ব লাগিব। আমি ইয়াক এটা পৰিৱৰ্তনশীল “টোটেল”ত সংৰক্ষণ কৰোঁ।

Task 2.2: Asking users to enter the numbers and storing them in the array. We use a for loop to access the elements. Here we use the variable “totalEle” for indexing. The index of the array elements goes from 0 to totalEle -1.

কাৰ্য্য 2.2: ব্যৱহাৰকাৰীসকলক নম্বৰবোৰ প্ৰবিষ্ট কৰিবলৈ কোৱা আৰু সেইবোৰ এৰেত সংৰক্ষণ কৰা। আমি উপাদানবোৰত প্ৰৱেশ কৰিবলৈ লুপৰ বাবে এটা ব্যৱহাৰ কৰোঁ। ইয়াত আমি সূচীকৰণৰ বাবে পৰিৱৰ্তনশীল “টোটেল” ব্যৱহাৰ কৰোঁ। এৰে উপাদানবোৰৰ সূচক 0 ৰ পৰা মুঠ ইলে -1 লৈ যায়।

Step 3: Calculating the summation of the array element.

পদক্ষেপ 3: এৰে উপাদানৰ সাৰাংশ গণনা কৰা।

We calculate the summation by visiting every element one. At each iteration of the loop, we add the element to the previously calculated summation.

আমি প্ৰতিটো উপাদান দৰ্শন কৰি সংক্ষিপ্তবিৱৰণ গণনা কৰোঁ। লুপৰ প্ৰতিটো পুনৰাবৃত্তিত, আমি আগতে গণনা কৰা সংক্ষিপ্তকৰণত উপাদানটো যোগ দিওঁ।

Step 4: Declaration of the result.

পদক্ষেপ 4: ফলাফলঘোষণা।

We do this by displaying the value of the variable ”sum”, Example 6.3 shows the complete C program.

আমি পৰিৱৰ্তনশীল ”যোগফল”ৰ মূল্য প্ৰদৰ্শন কৰি এনে কৰো, উদাহৰণ 6.3-এ সম্পূৰ্ণ চি প্ৰ’গ্ৰাম দেখুৱায়।

Example 6.3 A C program to find the summation of a series of numbers using an array.