47. JAVA Program to Display 1 to 99 Numbers in 5 Rows Sequential order.
How does this program work?
- This program is used to print 100 numbers for 5numbers in each line.
- Here we learn how to use loops concept to display numbers.
- Here we used two loops for loop and while loop.
Here is the code
// Sequentially numbers from 1 to 100
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<=5;i++ ){
System.out.print(" "+number);
number++;
}
System.out.println(" ");
}
}
}