plzz explain how works loop?? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

plzz explain how works loop??

int I,j,k; for(i=0;I<10;i++) { for(j=15;j>i;j++) System.out.println(" "); } for(k=0;k<i;k++) { System.out.println(" * "); } System.out.println(" \n");

16th Oct 2016, 7:14 PM
Javed
Javed - avatar
2 Réponses
+ 6
You had a few mistakes in your code: int i,j,k; for(i=0;i<10;i++) { for(j=15;j>i;j--) { System.out.print(" "); } for(k=0;k<i;k++) { System.out.print("*"); } System.out.print("\n"); } Test it here: https://code.sololearn.com/ceqM5SE0NeKi Loops are used to repeat a block of instructions while a condition is true. In a for loop, you have 3 statements that defines it: the first is run only when starting the loop, the second is the condition to loop, and the third is run at the end of each loop, before checking the condition. For example, in for(i=0;i<10;i++), you begin by initializing the variable i to 0, then you loop (execute the code between the brackets { } again and again) while i < 10, incrementing i by 1 at the end of each loop.
16th Oct 2016, 7:55 PM
Zen
Zen - avatar
0
tnx zen
17th Oct 2016, 9:36 AM
Javed
Javed - avatar