How to print the following output in the description section, with only use single loop. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to print the following output in the description section, with only use single loop.

Output: 123 456 789

16th Jun 2017, 5:49 PM
Zuher Yassin Saif Ali
Zuher Yassin Saif Ali - avatar
2 Answers
+ 3
/* JAVA code */ public class Program { public static void main(String[] args) { int i; for (i=1;i<10;i++) { if (i%3==0) { System.out.println(i); } else { System.out.print(i); } } } }
16th Jun 2017, 7:56 PM
visph
visph - avatar
- 2
C# version : just replace system.out.println with Console.WriteLine(I); and System.out.print with Console.Write(I);
17th Jun 2017, 4:42 AM
axel