write a java program to print a table integer using does while loop
Answers
You have to initialize the variable outside the loop. You have to put the condition in the while i.e.while(i>j). You have to put the increment or the decrement part inside the loop.
In this program, you'll learn to generate multiplication table of a given number. This is done by using a for and a while loop in Java.
Programiz
Search Programiz
Java Program to Generate Multiplication Table
In this program, you'll learn to generate multiplication table of a given number. This is done by using a for and a while loop in Java.
To understand this example, you should have the knowledge of the following Java programming topics:
Java for Loop
Java while and do...while Loop
Example 1: Generate Multiplication Table using for loop
public class MultiplicationTable {
public static void main(String[] args) {
int num = 5;
for(int i = 1; i <= 10; ++i)
{
System.out.printf("%d * %d = %d \n", num, i, num * i);
}
}
}
Output
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50
=Please do not report if the answer is wrong, we have tried our best to give you the correct answer}