+ 1
How to print the following output in the description section, with only use single loop.
Output: 123 456 789
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);
}
}
}
}
- 2
C# version : just replace system.out.println with Console.WriteLine(I); and System.out.print with Console.Write(I);