4.2.1 While loop

4.2.1 লুপ থাকোঁতে

Let us start with the While loop. Example 4.2 used a while loop construct. The signature of a while loop shown shows using Figure 4.1

আহক আমি ৱাইল লুপৰ সৈতে আৰম্ভ কৰোঁ আহক। উদাহৰণ 4.2-এ অলপ সময়ৰ লুপ নিৰ্মাণ ব্যৱহাৰ কৰিছিল। চিত্ৰ 4.1 ব্যৱহাৰ কৰি দেখুওৱা এটা সময়ৰ লুপৰ স্বাক্ষৰ

Figure 4.1: Signature of a while loop

The statements inside the while loop are executed as long as the condition evaluates as true. In case of Example 4.2, the condition was “value of the variable i is to be less than 5” and the statements were the printf() and the increment operation on i.

অৱস্থাটো সঁচা বুলি মূল্যাঙ্কন কৰালৈকে লুপৰ ভিতৰত থকা বিবৃতিবোৰ কাৰ্যকৰী কৰা হয়। উদাহৰণ 4.2-ৰ ক্ষেত্ৰত, চৰ্তটো আছিল “চলকৰ মূল্য মই 5-তকৈ কম হ’ব লাগিব” আৰু বিবৃতিবোৰ আছিল প্ৰিণ্টফ () আৰু আই-ৰ বৃদ্ধি অপাৰেচন।

At first, the condition of the while is checked. In case it evaluates as true, all the statements inside the loop are executed. After executing all the statements of the loop every time, the condition is checked. If the condition happens to be true, the statements are executed again. When the condition evaluates as false, the control comes out of the loop and executes the outside statements.

প্ৰথমে, সময়ৰ অৱস্থা পৰীক্ষা কৰা হয়। যদি ই সঁচা বুলি মূল্যাঙ্কন কৰে, লুপৰ ভিতৰত থকা সকলো বিবৃতি কাৰ্যকৰী কৰা হয়। প্ৰতিবাৰলুপৰ সকলো বিবৃতি কাৰ্যকৰী কৰাৰ পিছত, অৱস্থাটো পৰীক্ষা কৰা হয়। যদি চৰ্তটো সঁচা হয়, বিবৃতিবোৰ পুনৰ কাৰ্যকৰী কৰা হয়। যেতিয়া চৰ্তটো মিছা বুলি মূল্যাঙ্কন কৰে, নিয়ন্ত্ৰণটো লুপৰ পৰা ওলাই আহে আৰু বাহিৰৰ বিবৃতিবোৰ কাৰ্যকৰী কৰে।

Let us see another C program (Example 4.3) that uses a while loop. The program asks for entering an integer times. Every time a number is entered, the program displays the number back. The loop stops as soon as the value of the variable index reaches 5.

আহক আমি আন এটা চি প্ৰ’গ্ৰাম (উদাহৰণ 4.3) চাওঁ যিয়ে অলপ সময়ৰ লুপ ব্যৱহাৰ কৰে। প্ৰ’গ্ৰামটোৱে এটা ইণ্টেগাৰ সময়ত প্ৰৱেশ কৰিবলৈ কয়। যেতিয়াই এটা নম্বৰ প্ৰবিষ্ট কৰা হয়, প্ৰ’গ্ৰামটোৱে নম্বৰটো পিছলৈ প্ৰদৰ্শন কৰে। পৰিৱৰ্তনশীল সূচকৰ মূল্য 5 ত উপনীত হোৱাৰ লগে লগে লুপটো বন্ধ হয়।