Problem 2: Finding largest among three numbers.

সমস্যা 2: তিনিটা সংখ্যাৰ ভিতৰত সৰ্ববৃহৎ বিচাৰি উলিওৱা।

We have not solved this problem in this book yet. So let us first discuss the solution strategy. Then we will use a function for the same.

আমি এতিয়ালৈকে এই কিতাপখনত এই সমস্যাটো সমাধান কৰা নাই। গতিকে প্ৰথমে আমি সমাধানৰণ ৰণনীতিৰ বিষয়ে আলোচনা কৰোঁ আহক। তেতিয়া আমি ইয়াৰ বাবে এটা ফাংচন ব্যৱহাৰ কৰিম।

We are given three numbers: a, b, and c. Let us first try to answer – when we can say “a” is the largest number. The number “a” is the largest if it is greater than b and it is greater than c. So we make the first comparison between a and b.

আমাক তিনিটা সংখ্যা দিয়া হৈছে: ক, খ, আৰু গ। প্ৰথমে আমি উত্তৰ দিবলৈ চেষ্টা কৰোঁ আহক – যেতিয়া আমি ক’ ক’ব পাৰোঁ “ক” হৈছে সৰ্বাধিক সংখ্যা। “ক” সংখ্যাটো আটাইতকৈ ডাঙৰ যদি ই বিতকৈ ডাঙৰ হয় আৰু ই গতকৈ ডাঙৰ। গতিকে আমি ক আৰু খ ৰ মাজত প্ৰথম তুলনা কৰোঁ।

If a is greater than b, then we can compare a with c. If a is greater in both the cases, a is the largest. If a is not greater than c, then c happens to be the largest.

যদি ক খতকৈ ডাঙৰ হয়, তেন্তে আমি গ-ৰ সৈতে তুলনা কৰিব পাৰোঁ। যদি দুয়োটা ক্ষেত্ৰতে এ ডাঙৰ হয়, ক হৈছে আটাইতকৈ ডাঙৰ। যদি ক গতকৈ ডাঙৰ নহয়, তেন্তে গ আটাইতকৈ ডাঙৰ হয়।

Otherwise (if a is not greater than b), the largest can be either b or c. So we can do a comparison between b and c. If b is greater than c, then b is the largest. Otherwise c happens to be the largest.

অন্যথা (যদি ক খতকৈ ডাঙৰ নহয়), আটাইতকৈ ডাঙৰ টো হয় খ বা গ হ’ব পাৰে। গতিকে আমি বি আৰু গ ৰ মাজত তুলনা কৰিব পাৰোঁ। যদি খ গতকৈ ডাঙৰ হয়, তেন্তে খ হৈছে আটাইতকৈ ডাঙৰ। অন্যথা গ আটাইতকৈ ডাঙৰ হয়।

We present the logic using a flowchart as shown in Figure 7.2.0

চিত্ৰ 7.2.0-ত দেখুওৱাৰ দৰে ফ্লোচাৰ্ট ব্যৱহাৰ কৰি আমি যুক্তি উপস্থাপন কৰোঁ

Example 7.2 Flowchart for finding the largest among there numbers,

We now write a code segment for the above logic as shown below

আমি এতিয়া তলত দেখুওৱাৰ দৰে ওপৰোক্ত যুক্তিৰ বাবে এটা কোড খণ্ড লিখিছোঁ

The next job is to write a function for this. We will write the above code segment inside a function definition. The function accepts there numbers a, b and C as the parameters and returns the largest one. Following is the code segment.

পৰৱৰ্তী কামটো হ’ল ইয়াৰ বাবে এটা ফাংচন লিখা। আমি ওপৰোক্ত কোড খণ্ডটো এটা ফাংচন সংজ্ঞাৰ ভিতৰত লিখিম। ফাংচনটোৱে প্ৰাচল হিচাপে ক, খ আৰু চি নম্বৰ গ্ৰহণ কৰে আৰু সৰ্ববৃহৎটো ঘূৰাই দিয়ে। তলত কোড খণ্ড টো দিয়া হৈছে।

The complete C program is shown using Example 7.3. The program scans the numbers from the keyboard and then calls then calls a function find – largest () passing these numbers as parameters.

সম্পূৰ্ণ চি প্ৰ’গ্ৰামটো উদাহৰণ 7.3 ব্যৱহাৰ কৰি দেখুওৱা হৈছে। প্ৰ’গ্ৰামটোৱে কীবৰ্ডৰ পৰা নম্বৰবোৰ স্কেন কৰে আৰু তাৰ পিছত কল কৰে তাৰ পিছত ফাংচন এটাক কল কৰে – এই নম্বৰবোৰ পেৰামিটাৰ হিচাপে পাছ কৰা সৰ্ববৃহৎ ()।