Problem 6: Counting number of adult persons

সমস্যা 6: প্ৰাপ্তবয়স্ক ব্যক্তিৰ সংখ্যা গণনা কৰা

In This problem, We are given the age of a set persons and we need to write a function to find the persons who are adults.

এই সমস্যাটোত, আমাক এজন নিৰ্ধাৰিত ব্যক্তিৰ বয়স দিয়া হয় আৰু প্ৰাপ্তবয়স্ক ব্যক্তিবিলাক বিচাৰি উলিয়াবলৈ আমি এটা ফাংচন লিখিব লাগিব।

We know that a person is an adult it the age of the person is more than 18. We will use this very condition with a ”if” construct.

আমি জানো যে এজন ব্যক্তি প্ৰাপ্তবয়স্ক হয় ইয়াৰ বয়স ব্যক্তিজনৰ বয়স ১৮ বছৰতকৈ অধিক। আমি এই চৰ্তটো ”যদি” নিৰ্মাণৰ সৈতে ব্যৱহাৰ কৰিম।

In the first step, we will store the age of the persons in an array. In next stop, we will apply the logic to find the number of persons. We will perform these steps using two different functions.

আমি জানো যে এজন ব্যক্তি প্ৰাপ্তবয়স্ক হয় ইয়াৰ বয়স ব্যক্তিজনৰ বয়স ১৮ বছৰতকৈ অধিক। আমি এই চৰ্তটো ”যদি” নিৰ্মাণৰ সৈতে ব্যৱহাৰ কৰিম।

The program is shown using Example 7.8. In this program, we have used an array age [] to store the age of the persons. The variable personCount stores the total number of persons, that is the total number of array elements. Both the array age [] and person Count are declared as global so that both the function an input () and find Adult () can access them.

প্ৰ’গ্ৰামটো উদাহৰণ 7.8 ব্যৱহাৰ কৰি দেখুওৱা হৈছে। এই কাৰ্যসূচীত, আমি ব্যক্তিসকলৰ বয়স সংৰক্ষণ কৰিবলৈ এক এৰে বয়স [] ব্যৱহাৰ কৰিছোঁ। পৰিৱৰ্তনশীল ব্যক্তিগণনাত মুঠ ব্যক্তিৰ সংখ্যা সংৰক্ষণ কৰা হয়, যি হৈছে এৰে উপাদানৰ মুঠ সংখ্যা। এৰে বয়স [] আৰু ব্যক্তি গণনা দুয়োটাকে গোলকীয় হিচাপে ঘোষণা কৰা হয় যাতে ফাংচন টো এটা ইনপুট () আৰু প্ৰাপ্তবয়স্ক () বিচাৰি উলিয়াব পাৰে।

Example 7. 8: A C program for counting the number of adult persons

Have a look at the main () It simplay cally two functions: input () The find Adult() function runs through the array elements and checks whether the age is greater than or equal to 18.

মুখ্য () ই চিমপ্লে কেলি দুটা ফাংচন চাওক: ইনপুট () ফাইণ্ড এডাল্ট() ফাংচনটো এৰে উপাদানবোৰৰ মাজেৰে চলে আৰু বয়স 18-তকৈ ডাঙৰ নে সমান পৰীক্ষা কৰে।

if the age of the person is greater then or equal to 18, we anouce it and increment a counter adult count that was initially assigned to zero. See the ”if- else” clause inside find Adult ().

যদি ব্যক্তিজনৰ বয়স তেতিয়া অধিক বা 18-ৰ সমান হয়, আমি ইয়াক অনুমান কৰোঁ আৰু প্ৰথমতে শূন্যত আৱণ্টন কৰা এক কাউণ্টাৰ প্ৰাপ্তবয়স্ক গণনা বৃদ্ধি কৰোঁ। প্ৰাপ্তবয়স্ক বিচাৰি উলিয়াওক ()ৰ ভিতৰত ”যদি- অন্যথা” ধাৰাটো চাওক।

Fight 7.3 shows an exaction instance of the program where the user entered ages of 7 persons. Out of them. 4 persons were adults and the program rightly finds that.

ফাইট 7.3-এ প্ৰ’গ্ৰামটোৰ এক এক্সএকচন উদাহৰণ দেখুৱায় য’ত ব্যৱহাৰকাৰীয়ে 7 জন ব্যক্তিৰ বয়সত প্ৰৱেশ কৰিছিল। তেওঁলোকৰ পৰা। ৪ জন ব্যক্তি প্ৰাপ্তবয়স্ক আছিল আৰু কাৰ্যসূচীটোৱে সেইটো সঠিকভাৱে বিচাৰি পাইছে।

Example 7.3 An execution instance of problem 6.