5.1 INTRODUCTION TO NESTED LOOP

5.1 নেষ্টেড লুপৰ পৰিচয়

Whenever we write loop inside another loop, we call it a nested loop is called outer loop and the loop that apperars inside another loop is called the inner loop. There can be more than one inner loop in a program. The nested loop construct simplifies programing in many cases. This also reduces the program length.

যেতিয়াই আমি আন এটা লুপৰ ভিতৰত লুপ লিখোঁ, আমি ইয়াক নেষ্টেড লুপ বুলি কওঁ যাক বাহিৰৰ লুপ বুলি কোৱা হয় আৰু আন এটা লুপৰ ভিতৰত এপেৰাৰবোৰক ভিতৰৰ লুপ বুলি কোৱা হয়। প্ৰ’গ্ৰাম এটাত একাধিক ভিতৰৰ লুপ থাকিব পাৰে। নেষ্টেড লুপ নিৰ্মাণে বহুক্ষেত্ৰত প্ৰগ্ৰামিং সৰল কৰে। ই প্ৰ’গ্ৰামৰ দৈৰ্ঘ্যও হ্ৰাস কৰে।

The signature of a nested loop is priested below. Here loop i is called the ourter loop and loop 2 is called the inner loop.

এটা নেষ্টেড লুপৰ স্বাক্ষৰ তলত পুৰোহিত কৰা হৈছে। ইয়াত লুপ আইক আমাৰ লুপ বুলি কোৱা হয় আৰু লুপ 2 ক ভিতৰৰ লুপ বুলি কোৱা হয়।

We present a simple nested loop construct below where both the outer and inner loops are taken as while loops. The outer loop runs for i = 0 to 9 and for every i value, the inner loop runs for j = 0 to 19. The inner loop simply displays the values of i and j at each step. In the next section, we will solve some interesting problems using nested loop constructs.

আমি তলত এটা সৰল নেষ্টেড লুপ নিৰ্মাণ উপস্থাপন কৰোঁ য’ত বাহিৰৰ আৰু ভিতৰৰ দুয়োটা লুপ লুপৰ দৰে লোৱা হয়। বাহিৰৰ লুপটো মোৰ বাবে = 0 ৰ পৰা 9 আৰু প্ৰতিটো আই মানৰ বাবে, ভিতৰৰ লুপটো জে = 0 ৰ পৰা 19 ৰ বাবে চলে। ভিতৰৰ লুপটোৱে প্ৰতিটো পদক্ষেপত আই আৰু জেৰ মূল্যবোৰ প্ৰদৰ্শন কৰে। পৰৱৰ্তী শাখাত, আমি নেষ্টেড লুপ কনষ্ট্ৰাক্ট ব্যৱহাৰ কৰি কিছুমান আকৰ্ষণীয় সমস্যা সমাধান কৰিম।