+ 1
How to print 5 numbers per line?
4 Respostas
+ 12
You could do somthing like this in java..
for(int i = 1; i < 21;i++){
System.out.print(i+" ");
if(i%5==0){System.out.println();
}
}
if you want to keep the 0 use i-1+" " in the print statment
theres also a shorthand way if your intrested
for(int i =1; i < 21;i++){
System.out.print(i%5!=0?i:i+"\n");
}
😉👍
+ 4
It's easier to help you if you let us know what language you're asking about, maybe even give an example output etc.
+ 1
(answering with java syntax,change as suitable) keep an inner loop like for(j=0;j<5;j++) then ... System.out.print(whatever number u want to print)... and outside the loop write a blank println statement to go to new line
0
Java