4.1 IMPORTANCE OF LOOP IN PROGRAMMING LANGUAGE

4.1 প্ৰ’গ্ৰামিং ভাষাত লুপৰ গুৰুত্ব

Let us consider a simple C program as shown in Example 4.1. The program has 5 printf() statements. As a result, the program displays the sentence “I read in class X under SEBA” 5 times. Imagine for a while that we need to display the sentence 1000 times. Shall we write 1000 printf() statements?

উদাহৰণ 4.1-ত দেখুওৱাৰ দৰে এটা সৰল চি প্ৰ’গ্ৰাম বিবেচনা কৰোঁ আহক। প্ৰ’গ্ৰামটোত 5 টা প্ৰিণ্টফ() বিবৃতি আছে। ফলস্বৰূপে, প্ৰ’গ্ৰামটোৱে 5 বাৰ “মই ছেবাৰ অধীনত দশম শ্ৰেণীত পঢ়িছোঁ” বাক্যটো প্ৰদৰ্শন কৰে। কিছু সময়ৰ বাবে কল্পনা কৰক যে আমি বাক্যটো ১০০০ বাৰ প্ৰদৰ্শন কৰিব লাগিব। আমি 1000 প্ৰিণ্টফ() বিবৃতি লিখিম নেকি?

Example 4.1; AC program to print ”i read in class X under SEBA” 5 times.

We can obviously write 1000 printf() statements. But this is a horrible was of programing. Question is, is there any better way to do that? The answer is yes, using a concept called loop.

আমি নিশ্চিতভাৱে 1000 প্ৰিণ্টফ() বিবৃতি লিখিব পাৰোঁ। কিন্তু এইটো প্ৰগ্ৰামকৰাৰ এটা ভয়ংকৰ আছিল। প্ৰশ্ন হৈছে, এনে কৰাৰ আৰু কোনো ভাল উপায় আছে নেকি? উত্তৰটো হৈছে হয়, লুপ নামৰ ধাৰণা এটা ব্যৱহাৰ কৰি।

Whenever we need to do a work many times. we can write the work only once and put it inside a loop. Every programming language has this support. Loop it used for repeated execution of a set of statements in a program. We can rewrite the pervious program as shown in Example 4.2. We see that we have written the print () statement only instead of 5.

যেতিয়াই আমি বহুবাৰ কাম এটা কৰাৰ প্ৰয়োজন হয়। আমি কামটো কেৱল এবাৰহে লিখিব পাৰোঁ আৰু ইয়াক এটা লুপৰ ভিতৰত ৰাখিব পাৰোঁ। প্ৰতিটো প্ৰ’গ্ৰামিং ভাষাৰ এই সমৰ্থন আছে। এটা প্ৰ’গ্ৰামত বিবৃতিৰ এটা ছেট বাৰে বাৰে সম্পাদন কৰাৰ বাবে ইয়াক ব্যৱহাৰ কৰা লুপ কৰক। উদাহৰণ 4.2-ত দেখুওৱাৰ দৰে আমি ভেম্পটপ্ৰ’গ্ৰামটো পুনৰ লিখিব পাৰোঁ। আমি দেখিছোঁ যে আমি কেৱল 5 ৰ পৰিৱৰ্তে প্ৰিণ্ট () বিবৃতি লিখিছোঁ।

Example 4.2: C program to print ”I read in class X under SEBA”5 times.

উদাহৰণ 4.2: ”মই ছেবাৰ অধীনত দশম শ্ৰেণীত পঢ়িছো” 5 বাৰ প্ৰিণ্ট কৰিবলৈ চি প্ৰ’গ্ৰাম।

We can do many other interesting and important things using a loop. We will learn them gradually.

আমি এটা লুপ ব্যৱহাৰ কৰি আন বহুতো আকৰ্ষণীয় আৰু গুৰুত্বপূৰ্ণ কাম কৰিব পাৰোঁ। আমি সেইবোৰ ক্ৰমান্বয়ে শিকিম।