Why this program show "no output"???? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
12th Aug 2018, 4:24 PM
Harsh Agrawal
Harsh Agrawal - avatar
7 Answers
+ 1
1. Line 18 says System.out.println() so it doesnt print anything. 2. The if statement is outside for loop(with var j), so it will verify if c ==2 only at the end of that loop. 3. Please, use code identation, so the code can be more readable and clear. If you dont understand something, just ask✌
12th Aug 2018, 4:32 PM
Ledio Deda
Ledio Deda - avatar
+ 1
12th Aug 2018, 4:46 PM
Ledio Deda
Ledio Deda - avatar
+ 1
Lεd10 Dεda thnxzzzzz
13th Aug 2018, 9:23 AM
Harsh Agrawal
Harsh Agrawal - avatar
+ 1
Glad to help✌
13th Aug 2018, 9:46 AM
Ledio Deda
Ledio Deda - avatar
+ 1
Lεd10 Dεda nd also i want to ask that In my code i correct my mistake by taking c variable under outer loop so it wll work but the question why it is not working outside ????
13th Aug 2018, 1:43 PM
Harsh Agrawal
Harsh Agrawal - avatar
+ 1
If you declare int c = 0; outside the loops, it wont be 0 for every number i, like you want. So c == 2 will happen just one time or never.
13th Aug 2018, 2:47 PM
Ledio Deda
Ledio Deda - avatar
0
Lεd10 Dεda i want to print prime number between 1 to 100
12th Aug 2018, 4:34 PM
Harsh Agrawal
Harsh Agrawal - avatar