Posts

Showing posts with the label for loop

Loop Structure in Java जावा में लूप स्ट्रक्चर for loop, while loop, do...while loop

Java supports three types of loops: for loop , while loop , and do...while loop . These loops are used when a task needs to be repeated multiple times. जावा तीन मुख्य प्रकार के लूप का समर्थन करता है: for loop , while loop , और do...while loop . इनका उपयोग तब किया जाता है जब हमें एक ही कोड को बार-बार चलाना हो। ✅ (a) for Loop – Entry-Controlled Loop A for loop checks the condition before entering the loop. It has initialization, condition, and update parts written in a single line, separated by semicolons. It's ideal when the number of iterations is known. for लूप एक एंट्री कंट्रोल लूप होता है जिसमें कंडीशन को पहले चेक किया जाता है। इसमें इनिशियलाइजेशन, कंडीशन और अपडेशन एक ही लाइन में लिखे जाते हैं और अर्धविराम से अलग किए जाते हैं। इसका उपयोग तब किया जाता है जब पहले से पता हो कि लूप कितनी बार चलेगा। Java Program: public class ForLoopExample { public static void main(String[] args) { System.out.println("For Loop Output:"); for (int i = 1; i <...