48. JAVA Program to Display 1 to 99 Numbers in 5 Columns Sequential order.
How does this program work?
- This program is used to print 100 numbers for 5numbers in each column.
- Here we learn how to use loops concept to display numbers
- Here we used for loop to print numbers.
Here is the code
// To Print 1 to 100 numbers in 5 columns.
import java.util.Scanner;public class Number
{
public static void main(String args[])
{
int number=1;
//Print statement
System.out.println( "Numbers from 1 to 100:\n");//While loop, that will print numbers
//From 1 to 100
while(number<=100){
//For loop to print 5 numbers in a line
for(int i=1;i<=20;i++){
System.out.print(" "+number);
number++;
}
System.out.println(" " );
}
}
}