+ 1
[Solved]Why isn't this java program working? Please help me.
https://code.sololearn.com/cI91WRmtFfJ6/?ref=app I made this code but nothing is working. I attempted to make a program that displays a Triangle pattern on screen using numbers. If I enter 6 it should display: 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 Please tell me the error thank you. Edit: I corrected the code! Original code: public class Program { public static void main(String[] args) { int i,z; int n=6; for(i=1;i<=n;i++) { for(z=1;z<=i;z++); { System.out.print(i+" "); } System.out.println(); } } }
5 Réponses
+ 7
The Problem that in your inner loop you hve added semicolon at loop.
public class Program
{
public static void main(String[] args) {
int i,z;
int n=6;
for(i=1;i<=n;i++)
{
for(z=1;z<=i;z++)
{
System.out.print(i+" ");
}
System.out.println();
}
}
}
+ 2
It's Roy remove the semicolon after second for loop
+ 1
💫💫 i think i said same, you could have corrected me for the spelling mistake atleast .
I thought we had a awesome helpful community in here but all i see is people with many followers giving out their opinions (even when someone posted before) without correcting at all the others who are trying to help and believe me this is really toxic , no offense to you but just saying what i have been noticing.
0
Thank you! 💫💫
0
Ответ 🙏🙏🙏🙏