write an algorithm to print the table of 5
Answers
Explanation:
Step 1:
Start
Step 2:
Input N, the number for which multiplication table is to be printed.
Step 3: For
T = 1 to 10
Step 4:
Print M = N * T
Step 5:
End For
Step 6: Stop
Answer:
An algorithm is a finite sequence of exact instructions that is used in mathematics and computer science to solve a class of particular problems or carry out a computation.
Step1: Start
Step2: Input N=5
Step3: Input T=1 to 10
Step4: Print M=N*T
Step5: End
Where T is the table and N is the input number
Code:-
// Java program to print table of a number
import java.io.*;
class table
{
// Driver code
public static void main(String arg[])
{
// Change here to change output
int n = 5;
for (int i = 1; i <= 10; ++i)
System.out.println(n + " * " + i + " = " + n * i);
}
}
#SPJ2