
How to print a table using while loop?

The given example displays the multiplication table of the given number. This program accepts the integer value generate the table of that number.
public class WhileDemo{
public static void main(String []args){
int x =5;
int y =1;
System.out.println(" Table of " + x +" = ");
while(y<=10)
{
int t = x * y;
System.out.println(t);
y++;
}
}
}
Output
Table of 5 =
5
10
15
20
25
30
35
40
45
50
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.