There are some such topics. What I don't understand even after trying ... Please answer me with logic | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

There are some such topics. What I don't understand even after trying ... Please answer me with logic

Loop and patterns in java

10th Feb 2022, 12:56 PM
Ujawal Tiwari
Ujawal Tiwari - avatar
2 Answers
+ 1
Thanks 😊
10th Feb 2022, 7:11 PM
Ujawal Tiwari
Ujawal Tiwari - avatar
0
A loop is a way to repeat a set of instructions. Looping saves the programmer from having to retype similar instructions over and over. A loop should have an exit condition so that it does not repeat forever. Usually the exit condition depends on one or more values that change each time through the loop, such as a counter that tracks how many times the loop repeated. When printing patterns the loop counter (a.k.a index) becomes the row number. Think about what changes from line to line - how many spaces, how many printable characters, etc. When you can identify those differences, try to formalize it logically or mathematically. You can approach it a couple ways. Can you describe what changes relatively from row to row? Or another way, can you describe the pattern absolutely if given only the row number? Sometimes you have to break up the pattern into sections that are handled by more than one loop or nested loops. Now see this for examples: https://www.javainterviewpoint.com/pattern-programs-in-java/
10th Feb 2022, 6:43 PM
Brian
Brian - avatar