Problem 3: Finding largest among a series of numbers

সমস্যা 3: সংখ্যাৰ এটা শৃংখলাৰ ভিতৰত সৰ্ববৃহৎ বিচাৰি উলিওৱা

We have already solved this problem in Chapter 6. We will now write a function for the same.

আমি ইতিমধ্যে অধ্যায় ৬ ত এই সমস্যাটো সমাধান কৰিছো। আমি এতিয়া ইয়াৰ বাবে এটা ফাংচন লিখিম।

While tackling the problem in Chapter 6, we stored the numbers in an array. Then we applied the logic for finding the largest number.

অধ্যায় 6-ত সমস্যাটোৰ মোকাবিলা কৰোঁতে, আমি সংখ্যাবোৰ এটা এৰেত সংৰক্ষণ কৰিলোঁ। তেতিয়া আমি আটাইতকৈ ডাঙৰ সংখ্যাটো বিচাৰি উলিওৱাৰ যুক্তি প্ৰয়োগ কৰিছিলো।

Here, we will write this logic inside a function and then we will call the function from main(). Example 7.4 shows the complete program. In the program, we have passed only the number of elements (variable totalEle) as the parameter to the function find_lagest().

ইয়াত, আমি এই যুক্তিটো এটা ফাংচনৰ ভিতৰত লিখিম আৰু তাৰ পিছত আমি ফাংচনটো কল কৰিম মেইনৰ পৰা()। উদাহৰণ 7.4-এ সম্পূৰ্ণ প্ৰ’গ্ৰামটো দেখুৱায়। প্ৰ’গ্ৰামটোত, আমি কেৱল ফাংচন find_lagest() প্ৰাচল হিচাপে কেৱল উপাদানৰ সংখ্যা (পৰিৱৰ্তনশীল টোটেল) প্ৰেৰণ কৰিছোঁ।

We have also learned some new syntax of the language here. First, have a look at line number 2. In the function declaration, we have not written the parameter name; we have only written the data type.

আমি ইয়াত ভাষাটোৰ কিছুমান নতুন বাক্যবিন্যাসও শিকিছোঁ। প্ৰথমে, শাৰী নম্বৰ 2 চাওক। ফাংচন ঘোষণাত, আমি প্ৰাচলনাম টো লিখা নাই; আমি কেৱল ডাটা প্ৰকাৰ লিখিছোঁ।

Next, we have declared the array number[20] outside the main(). This makes the variable number a global variable. When we make a variable global, any function in the program can directly access that variable. As a result, it becomes possible for the function find_largest() to use the array number (line numbers 3, 5 and 6 in the function definition).

ইয়াৰ পিছত, আমি মুখ্য ()ৰ বাহিৰত এৰে নম্বৰ[20] ঘোষণা কৰিছোঁ। ই পৰিৱৰ্তনশীল সংখ্যাটোক এক গোলকীয় পৰিৱৰ্তনশীল কৰি তোলে। যেতিয়া আমি এটা পৰিৱৰ্তনশীল গোলকীয় প্ৰস্তুত কৰোঁ, প্ৰ’গ্ৰামৰ যিকোনো ফাংচনে পোনপটীয়াকৈ সেই চলকটো প্ৰাপ্ত কৰিব পাৰে। ফলস্বৰূপে, ফাংচন find_largest() এৰে নম্বৰ (ফাংচন সংজ্ঞাত শাৰী নম্বৰ 3, 5 আৰু 6) ব্যৱহাৰ কৰা সম্ভৱ হয়।