I've been given this problem and I need to use a loop to create these patterns. I remember using a while loop and im not very familiar with a for loop. the programming language here is java. i'm more familiar with python and even with that language i struggled to do this. how do i use a loop to create these patterns? was the while loop the wrong idea and maybe i should've for looped it? here are the instructions i was given, i cant seem to create the pattern Printing a single character at a time create loops to Print the following patterns: Pattern 1: * ** *** **** Pattern 2 * *** ***** *** * Pattern 3 1010101 10101 101 1
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
I've been given this problem and I need to use a loop to create these patterns. I remember using a while loop and im not very familiar with a for loop. the
i'm more familiar with python and even with that language i struggled to do this.
how do i use a loop to create these patterns?
was the while loop the wrong idea and maybe i should've for looped it?
here are the instructions i was given, i cant seem to create the pattern
Printing a single character at a time create loops to Print the following patterns:
*
**
***
****
*
***
*****
***
*
Pattern 3
1010101
10101
101
1
Use of for loop: We use for loop when we know how many times the loop will going to execute.
Use of while loop: We use while loop when don't know the number of the times loop will going to execute.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images